How would you style only the first list item of an unordered list in CSS?

  • ul li:first-child
  • ul li:nth-child(1)
  • ul:first-child li
  • ul:first-of-type li
To style only the first list item of an unordered list in CSS, you should use the ul li:first-child selector. This targets the first li element within a ul element. It's important to note that :first-child targets the first child of its parent, not the first of its type.
Add your answer
Loading...

Leave a comment

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