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 ID Selectors

Bára Paulátová
Bára Paulátová
3,583 Points

page can only have one element with the same ID name?

we assigned the primary-content ID to <div>, and then I tried to assign it to random <p> and it worked .. so please, could anyone explain to me why cant I use the same ID name for more than one element?

is it because of the other functions we use the ID for? like #top function?

thanks for your answers, Bára

1 Answer

You will need to use class instead of ID if you want to assign it to more than one element. ID is used specifically for one element where as class can be used on multiple elements.

Bára Paulátová
Bára Paulátová
3,583 Points

Thanks for a quick reply! With your answer and the next video about classes, I understand :)