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 Foundations Selectors Class and ID Selectors

at the 3M 17S mark of the video ... why is a class .main-header... created instead of an ID since its used 1x pr page?

...

1 Answer

Eric Martz
Eric Martz
16,007 Points

Nathan,

I am sure Guil had his own reasons, but from what I have read it is best practice to use classes rather than ID's. The two main reasons are code-reuse and specificity issues. You're right that the header will only appear once per page, so my guess would be to use a main-header class to prevent specificity issues.

Eric