How to create links to sections within an Html page

Photo by Jackson So on Unsplash

How to create links to sections within an Html page

An anchor tag is used to create a hyperlink that allows users to flow through sections of a page and can also be used to transfer the users to a different webpage.

Syntax:

<a href="link"></a>

To create an anchor link, an id attribute is added to an element to name it. More than one element on a webpage should not have the same id name. When naming an id, instead of using spaces to separate words an underscore would be more appropriate.

<div id="element_name"></div>

After naming each element, create a hyperlink with the use of an anchor element and then input the target the id name (preceded by a #)

<a href="#element_name"></div>

carbon (4).png