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 trialYoko Iseki
Front End Web Development Techdegree Student 7,524 PointsWhy "Item 1" is not affected by :only-child?
I'm wondering why "Item 1" is still in white, even :only-child {color: #52bab3} comes after :first-child {color: white}...
According to the CSS override rules, I thought "Item 1" would be in teal(#52bab3) as well. Am I missing something?
2 Answers
Steven Parker
231,268 PointsRules with higher specificity always take precedence, even over something that comes later.
Since li:first-child
has both a tag name and a pseudo-class, it has a higher specificity than :only-child
which is just a pseudo-class.
Yoko Iseki
Front End Web Development Techdegree Student 7,524 PointsHigher specificity! I focused on just :first-child & :only-child, not li..I completely ignored it. I feel relieved now...thank you so much Steven!