HTML Introduction to HTML and CSS HTML: The Structural Foundation of Web Pages and Applications Anchor Tags

Cate C
Cate C
4,734 Points

#top -- not a standard, is it?

The course states that #top in href will create a jump link to the top of the page. However, the code does not contain any id with the value "top". Searching online I can find nothing stating that using "top" in href without defining it is a new standard. Is this defined in HTML5 as a standard? or just commonly used?

4 Answers

Jennifer Nordell
MOD
Jennifer Nordell
Treehouse Moderator

I agree with Steven Parker. That being said, there is MDN documentation on just this subject! This behavior is specified in HTML5.,

Hope this helps! :sparkles:

Steven Parker
Steven Parker
149,029 Points

Excellent reference. I did not know where to find the documentation this time.
Usually it's the other way 'round: I don't remember the fact until I look it up again in the docs.

Steven Parker
Steven Parker
149,029 Points

I think most browsers treat the top of the page as if it had the ID of "top", but only if no actual "top" ID exists. If you give an element the ID of "top", then an href of "#top" will point to it instead of the top of the page.

A more universal standard (and reliable reference) for the top of the page is just "#" by itself.

Kieran Barker
Kieran Barker
Full Stack JavaScript Techdegree Student 12,374 Points

No, I don't think it's a standard. Using the # symbol on its own would do the same thing.

Cate C
Cate C
4,734 Points

Yes, Jennifer, that is very helpful and good to know that it is part of HTML5. Thanks all for your responses