How to Hyperlink HTML

Here's five examples of how to hyperlink HTML documents. To create a hyperlink, copy the desired HTML code and paste it into your HTML documents.

This is the bare-bones basic hyperlink.

HTML code

Absolute path example:

<a href="https://example.com/">Some Text</a>

Relative path example:

<a href="/some-file.html">Some Text</a>

Result: Link Text

Used to provide additional information about the link when a user hovers over the link. Best practice is not to provide information that the reader already knows about.

HTML code

<a href="https://example.com/" title="This is a link to my home page.">Link Text</a>

Result: Link Text

This HTML will open link in new tab. When browsers didn't have tabs, this used to open the link in a new browser window.

Attributes

For security reasons, when using the target attribute with the value of _blank, it is considered best practice to include the rel attribute with the value set to noopener as seen below.

HTML code

<a href="https://example.com/" rel="noopener" target="_blank">Link Text</a>

Result: Link Text

All of the above attributes together in one hyperlink.

HTML code

<a href="https://example.com/" target="_blank" rel="noopener" title="This is a link to my home page.">Link Text</a>

Result: Link Text

Notes

  • Replace https://example.com/ with your actual URL.
  • Replace Link Text with your desired link text.
  • Note: For demonstration purposes, the Result links only link to this page.

More