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 Basics (2014) Basic Selectors Descendant Selectors

Victor Gordian
Victor Gordian
4,656 Points

Can you id and class anything?

So whatever is nested inside the header or body, i can id or class it? or are there some sort of rule that only lets select some things inside the body or header

2 Answers

Sebastian Mercado
Sebastian Mercado
8,800 Points

Yes, you can apply a class or id to any element within the body. You can also apply a class or id to the header since the header is inside the body element. A specific id can only be used once, where as a class can be used through out the website. Classes should be used more often than id's. Hope this helps.

Also worth noting:

ids have a lower specificity than classes. So if you have a class and an id on an element, the id CSS will override any class CSS

Nicolás Carrasco-Stevenson
Nicolás Carrasco-Stevenson
Courses Plus Student 5,668 Points

You mean id selector have HIGHER specificity than class selectors. More specific rules will always override less specific rules