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

Using " id='top' " Opposed To " name='top' "

Is there much of a difference between using "id" or "name", for example when naming the header "id=top"? The only difference I can see is when using "id", the link after the footer takes you to the top of the element and when "name" is used, it takes us to the top of the body.

2 Answers

Andrew Dushane
Andrew Dushane
9,264 Points

The name attribute is an older way of doing it that's not supported in HTML5. You want to use id because it's the current, accepted way to do it.

Andrew Dushane
Andrew Dushane
9,264 Points

Also it lets you anchor and style an element with one attribute rather than two, which I'm guessing is why it's the recommended way.

Ahh, thanks Andrew.