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

Link parts of a web page

How to link to a specific part in a web page

2 Answers

Steven Parker
Steven Parker
231,248 Points

The part you wish to link to should be given an "id" attribute if it does not already have one.

Then to link directly to that part from the same page, use that ID as the "href" of the link with a "#" symbol in front of the name. If the link is to a different page, put the "#" and the id immediately after the URL in the "href".

For example:

<p id="linkme">This is the spot you want the link to go to</p>

<!-- then elsewhere on the page -->
<a href="#linkme">Click here to go to the other part of the page</.a>

And for a practical example, click here to go to the question part of this page.

Thanks, this worked

Fran ADP
Fran ADP
6,304 Points

use 'href' when using links.