CSS CSS Selectors Going Further with Attribute Selectors and Pseudo-Classes :first-child and :last-child

professionalb
professionalb
Full Stack JavaScript Techdegree Student 5,082 Points

UL instead of OL ?

In this video, he is updating the first and list child from an unordered list, but he is using OL.

Shouldn't it be?

ul:first-child {
  background: #52bab3;
  color: white;
}

ul:last-child {
  border: none;
}

1 Answer

Olivia Culver
Olivia Culver
Full Stack JavaScript Techdegree Student 15,423 Points

He's actually referencing the 'li' elements instead of the entire list element. He chooses the 'li' element instead of the 'ul' list element because the ':first-child' pseudo class represents the first element among a group of sibling elements rather than the first child element of a parent element. He writes

li:first-child {
  background: #52bab3;
  color: white;
}

li:last-child {
  border: none;
}

I hope this helps!