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 trialmimik2
14,766 PointsBack to top
Without adding the attribute "top" to the header and #top to the footer, I was still able to click on Back to top and get to the top of the webpage. Is it necessary to add the "top" attribute?
2 Answers
Falk Schwiefert
8,706 PointsIn general this functionality is working through anchor tags within the document. This means that you need an anchor tag with a specified name somewhere and an link to said anchor somewhere else in the document.
<!-- tag you want to jump to -->
<a name="your_anchor_name"></a>
<!-- clickable link in the document -->
<a href="#your_anchor_name">Back to top of page</a>
These things obviously don't just work for going back to the top of a page but can also be used to jump between paragraphs or headlines or whatever else you feel the user might want a quick way to get to.
Jeremiah Shore
31,168 PointsIt is appearing to work without the id in the header element and the value in the href attribute of the anchor element because the link is taking you to the destination of index.html#, which simply reloads the file/page in your browser. The page load takes you to the top of a page because there is no anchor point specified through use of an id.
If you add an id to an element lower in the page, link to that, and then make your browser as narrow as possible, the difference of effect is more noticeable in these example files.
Julie Myers
7,627 PointsJulie Myers
7,627 PointsCould you copy and paste your coding?