How to create an HTML link on a web page

Updated: 06/30/2019 by Computer Hope
HTML a href tag

To create a link on your web page or blog to another page requires an HTML a href tag be inserted into the body section of HTML source code. Below are two examples with additional information of the different types of links you can insert into a page.

Absolute HTML link example

<a href="">Computer Hope</a>

In the above example, this link is an absolute path link that points to the Computer Hope homepage as shown below. As long as the Computer Hope web page is up and running and you have an Internet connection you can visit the link with no errors.


Computer Hope


With an absolute link, you can link to any URL shown in your Internet address bar. For example, if you wanted to link to this page you could copy the " " address and paste it into the href portion of the link.

Relative HTML link example

In the example below, this link is a relative path link and points to a file in the same directory as the page with the link.

HTML a tag

If the file "hope.html" did not exist in the same directory as the page trying to link to the page, you would get a 404 error. What makes a relative link unique is that it allows you to link to a page that will work online or offline and that can be copied to any server without any errors.

Additional anchor attributes

The anchor tag also supports other attributes. For example, you could add the title attribute to describe the link as shown in the link below when hovering the mouse pointer over the link. See the link below for additional attributes that can be added to the anchor.