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

Why did Guil choose to use a class selector to target the <span> instead of an ID selector?

Is there a preference to use one over the other or could he have used an ID, or is there something I'm not realizing?

1 Answer

Jamie Reardon
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Jamie Reardon
Treehouse Project Reviewer

Classes are reusable, so therefore, the styles that Guil may have applied to that span would therefore be reusable by adding that class to other elements on the page, e.g. another span element. ID selectors carry more weight than classes, and are used for styling and defining unique elements on the page, an element cant have more than one id and a page cant have more than one id with the same name. ID's are therefore used mainly to internally link to different sections of a page and or used for javascript purposes and so forth.

Thank you!