Read the CSS selectors – the basics tutorial for a primer on selectors first.

I love that CSS3 allows the zebra-striping of tables using the nth-child() selector. Achieving this in plain HTML is a messy manual process that must be repeated should the contents/row order of the table change. The CSS solution is far easier to implement. The nth-child() selector can be a number, a keyword, or a formula.

See the Pen Zebra-striping table using CSS3 by David Fox (@foxbeefly) on CodePen.

Read more about the CSS’s :nth-child() selector here: https://www.w3schools.com/cssref/sel_nth-child.asp


References:

  1. W3schools (No date) CSS :nth-child() Selector. Available at: https://www.w3schools.com/cssref/sel_nth-child.php (Accessed: 4 March 2024).

By MisterFoxOnline

Mister Fox AKA @MisterFoxOnline is an ICT, IT and CAT Teacher who has just finished training as a Young Engineers instructor. He has a passion for technology and loves to find solutions to problems using the skills he has learned in the course of his IT career.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.