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

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

There is an error in the anchor tag section when I apply the a href tag with #top and refresh the page it do

Hello everyone,

I think there is an error in the anchor tag lesson 10:20 am So when I apply the a href tag with #top and refresh the page it does not work probably because is needed a class placed at the top in the head section?

Please let me know

7 Answers

You're welcome. Happy to help! Make sure to ask again if something does not work :)

She 100% does that. Maybe they forgot to show where she writes that in the video. Now your a tag is looking for an element that has an id "top". You want it to go back to the top of the page, so place the id "top" on the element that is on top of the page. For example header.

<header id="top">This is a header</header>

This way, whenever you click that link (a href tag) it will scroll up to the header. Let me know if you got it

Amy Chatas
seal-mask
.a{fill-rule:evenodd;}techdegree
Amy Chatas
Front End Web Development Techdegree Student 158 Points

Tom Achki I did as you recommended but changed it to:

<header id="top"></header>

When I included the words: This is a header as you indicated...it adds those words at the top of the page. I didn't want to see that so removed the words and still make it to the top of the page.

This is how my code looks like with the a href tag:

 <p><a href="#top"><img src="http://placeimg.com/400/480/people" alt="Drawing of Jane Smith" class="profile-image">This is a third paragraph</a></p>

I haven't placed an ID yet, where shall I place it? She does not do that in the video?

I have placed the id inside the header tag as follows: id="top" and now it is working!

Thanks a bunch Tom!

When you type <a href="#top"></a>, the website looks for an element that has an id "top". Make sure to give the id "top" to the element that is on top of the page such as header or navigation bar.

I understand, but in the video she does not do that. Why? thanks!

that is a good solution. you can also write like this, <p><a href="#"><img src="http://placeimg.com/400/480/people" alt="Drawing of Jane Smith" class="profile-image">This is a third paragraph</a></p> - which is a built in command navigating you to the top of the page

At this time this is to advanced for me!!!