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

rob111
rob111
8,379 Points

ID is being applied to multiple instances on same page.

I gave several P elements the id="primary-content" and they all received the red border. But the video states I can only use 1 id per element, per page.

Shouldn't the border NOT be applied to all instances?

2 Answers

Kevin Korte
Kevin Korte
28,149 Points

It'll work, browser will let you use multiple ids on the same page, but it's not best practices, and you should avoid doing so. A class would the be appropriate choice here.

Moritz Lang
Moritz Lang
25,909 Points

Mh, I think they meant that you should not reuse an ID as it doesn't makes sence. If you want to apply something to multiple elements classes are better suited.