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 trialMatthew Whittington
10,308 PointsHow is href="#top" taking me to the top of the page when top is not defined in the code?
Wouldn't the id of the top div have to be set to top for this to work? Or is it only working because top isnt defined?
4 Answers
Kyle Johnson
33,528 PointsHere is some documentation! Scroll down to the "Attributes" section and then to the "href" attribute. There you will find a note explaining that you can use an ID of "top". There is also a link to the HTML5 explanation in this note.
Rick Buffington
8,146 PointsModern browsers recognize the anchor #top as being the top of the page - even if you do not define it. Same goes for #bottom.
Matthew Whittington
10,308 PointsDo you have any documentation on that?
Matthew Whittington
10,308 PointsDo you have any documentation on that?
Rick Buffington
8,146 PointsI honestly do not have documentation for the browser going to the top or bottom - just experience with it. However, if you are just looking for information on anchor tags in general, google has a plethora of sources. WW3 schools is great.
Brandon Miller
6,818 PointsThis was helpful. Also, I found this at the above reference: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a
"Note: You can use href="#top" or the empty fragment href="#" to link to the top of the current page."
goshgarhuseynov
Front End Web Development Techdegree Student 10,873 PointsYou can also find this href attribute values at the the following site; https://www.w3schools.com/tags/att_a_href.asp. However in my Chrome the #bottom value does not work.