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

Karem Ortiz
Karem Ortiz
1,201 Points

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

5 Answers

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

Karem Ortiz
Karem Ortiz
1,201 Points

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.

Karem Ortiz
Karem Ortiz
1,201 Points

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

Karem Ortiz
Karem Ortiz
1,201 Points

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?

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