You have a complex web page layout with nested elements. You want to specifically style an element that is the second child of its parent, regardless of the type of element. Which pseudo-class selector will ensure your style is applied correctly?
- :child(2)
- :nth-child(2)
- :nth-element(2)
- :second-child
The correct selector is :nth-child(2). This targets the second child element of its parent, irrespective of the element type. :second-child and :child(2) are not valid selectors, and :nth-element(2) is not a standard selector in CSS.
Loading...
Related Quiz
- What does the CSS property "line-height" primarily affect?
- What does the 'box-sizing' property with a value of 'border-box' do?
- To use a custom property in your styles, you reference it with the ________ syntax.
- You're building a website's header and you want it to stay at the top of the viewport when users scroll. Which positioning property would you use?
- What is the purpose of the CSS border-style property?