How we can highlight selected row in a table using css. Is there any way to do that?
How do you highlight a row if a cell contains text? Select the cells you want to apply conditional formatting to. Click the first cell in the range, and then drag to the last cell. Click HOME > Conditional Formatting > Highlight Cells Rules > Text that Contains.
When you create Web pages in HTML, you can use JavaScript functions to alter the appearance of page elements on user interaction. To highlight certain rows in a table, you can set Cascading Style Sheet declarations for these rows in their normal state and in their highlighted state.
How Do I Highlight Text In CSS? To Highlight text in HTML you have to use an inline element such as the <span> element and apply a specific background style on it. This will create the highlighting effect, which you can tweak in many different ways to create different looks.
Assuming that by "selected" you mean "hovered over by mouse":
tr:hover {background-color: #FF0000}
You could also highlight with things like 'font-weight:bold', 'color: #FF000', etc..
tr { background: sky-blue-pink } /* Use a real colour */
tr * { background: transparent; }
where tr
is a more specific selector to indicate whatever condition you have in the DOM to represent 'selected'. This will probably be a class selector: tr.selected
You just have to do something like:
tr:hover { background: #FCF; }
See this example.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With