How can the nth-child pseudo-class selector be used to style table rows?

  • To select and style the first row of a table. 
  • To style every nth-row in a table. 
  • To style rows based on their child elements. 
  • To style the table header only. 
The :nth-child() pseudo-class selector in CSS is used to match elements based on their position in a group of siblings. In the context of table rows (

elements), it can be employed to apply styles to every nth-row. For example, tr:nth-child(even) { background-color: #f2f2f2; } will apply a background color to every even row in a table, creating a zebra-stripe effect. 
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *