On UrbanPro

View My Profile       Proud to be a Teacher       Write a Review  

Thursday, September 15, 2016

Make Links Within An HTML Page

Any element on the page can have an id attribute. It can be done like this:

<p id="section">This is a paragraph.</p>

When you use a hash symbol # in a link it will go to the element which has an id attribute the same as the string that follows the hash. You can link to it like this:

<a href="#section">Go to section</a>

This also works if you're going there from another page and want it to scroll down:

<a href="page.html#section">Go to section on page.html</a>

Popular Posts