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.
Add your answer
Loading...

Leave a comment

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