What is the use of nth-child() selector in CSS?
Back to QuestionsIt is used to inherit the properties of the parent element.
If nth-child() is given for an element, it will automatically take some pre-defined styles.
It is used for zebra-striped tables.
It is used to give proper spacing between the parent element and child element.
It is generally used to display different background-colors for even and odd rows in tables.
For zebra-striped tables, use the nth-child() selector and add a background-color to all even (or odd) table rows.