Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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

professionalb
seal-mask
.a{fill-rule:evenodd;}techdegree
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
seal-mask
.a{fill-rule:evenodd;}techdegree
Olivia Culver
Full Stack JavaScript Techdegree Student 15,439 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!