Hoverable Table
The hoverable Table effect on each row can be achieved by using:hover selector to the <tr> element
Example: Illustration of creating a Hoverable Table effect using different CSS properties.
HTML
<!DOCTYPE html> < html lang = "en" > < head > < meta charset = "UTF-8" > < meta name = "viewport" content=" width = device -width, initial-scale = 1 .0"> < title >HTML Table Styling</ title > < style > h1, h3 { text-align: center; color: green; } table { width: 100%; border-collapse: collapse; } th, td { padding: 1px; text-align: center; border-bottom: 1px solid black; } tr:hover { background-color: rgb(205, 243, 187); } </ style > </ head > < body > < h1 >w3wiki</ h1 > < h3 >Hoverable Table</ h3 > < table > < thead > < tr > < th >Name</ th > < th >Class</ th > < th > Roll No </ th > </ tr > </ thead > < tbody > < tr > < td >Mahima</ td > < td >10</ td > < td >1</ td > </ tr > < tr > < td >Krishn</ td > < td >8</ td > < td >3</ td > </ tr > < tr > < td >Shivika</ td > < td >8</ td > < td >5</ td > </ tr > </ tbody > </ table > </ body > </ html > |
Output:
HTML Table Styling
HTML Table Styling offers various styling techniques to make the table more presentable and attractive. The article will cover various HTML Table Styling including, HTML Table Styling-Zebra Stripes using tr:nth-child(even)
, Vertical Zebra Stripes using td:nth-child(even) and th:nth-child(even)
and many more using different CSS properties.