You are tasked with creating a list where every even item has a gray background. Which CSS selector would help you accomplish this?
- :even
- :nth-child(even)
- :nth-child(odd)
- :odd
To select every even item in a list, you should use the :nth-child(even) selector. This will apply the styling to the elements with even indices in the list, which will give them a gray background in this scenario.
Loading...
Related Quiz
- What is the primary purpose of the grid-template-areas property?
- Which property allows you to control the size of tracks in a grid layout?
- In the context of a CSS preprocessor like SASS, what does "nested rules" mean?
- To create a shadow effect behind an element, you'd use the ________ filter.
- In a media query, which feature is commonly used to detect the width of the viewport?