How to create links to sections on the same page in HTML
HTML Hyperlinks are used to navigate from one web page to another. We can also use same <a> anchor tag to jump between different sections of same web page.
To know how to insert hyperlink to navigate within different page, go through HTML Links.
In this tutorial you will learn how to link one section to another section on a same web page.
Internal Links
In case of long pages, we can help users to explore page by using internal links without scrolling. User can jump between different sections of page on single click. Internal links/page jumps use the same <a> tag and href attribute. Link provided as value of href attribute points to particular section of page.
Syntax
Page jumps are done by using the name attribute of the a element. suppose we need a link to the top of your page, you would add an anchor like this near the top of your document.
<a name="name_attribute_value"></a>
There doesn’t need to be anything between the opening and closing tags. As per our need we can use <a> tag with same content also. like,
<a name="name_attribute_value">section of page</a>
After this put <a> tag in page from where we want user to link for navigation
<a href="#name_attribute_value">Visible link text</a>
hash mark (#) tells the browser that it’s a section of a page it’s looking for, and not a separate page or folder. So just make a link to the section you named earlier. Always remember, the # goes in the href attribute’s value, not in the name.
HTML Hyperlink:
Comments
Post a Comment