Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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,426 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!