I want to have my table rows highlighted on mouse over, but I have yet to find a way to do it that isn't using Javascript. Is this not possible in CSS?
I've tried this:
tr:hover { background: #000; }
But that doesn't work. Using td:hover
works, but I want to change the background colour of the whole table row.
Is there a pure CSS/HTML way to do it, or am I going to have to resort to Javascript?
HTML | <tr> bgcolor Attributecolor_name: It sets the background color by using the color name. For example “red”. hex_number: It sets the background color by using the color hex code.
Changing link color on hover using CSS To change the color of your link on hover, use the :hover pseudo property on the link's class and give it a different color.
How to Add Background Color in HTML. To add background color in HTML, use the CSS background-color property. Set it to the color name or code you want and place it inside a style attribute. Then add this style attribute to an HTML element, like a table, heading, div, or span tag.
How to color specific row in a CSS Table. You can use the tr:nth-child(rownumber) to color a particular row in a table using CSS. Above code select the 3 row from top (including table head row) and color background as green and foreground as white.
<tr>
s themselves are very hard to access with CSS, try tr:hover td {background:#000}
You could try:
tr:hover { background-color: #000; } tr:hover td { background-color: transparent; /* or #000 */ }
JS Fiddle demo.
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