HTML Links


HTML links are known as hyperlinks

You can click on a link to navigate to another webpage

A link does not have to be text, it can be any HTML element.


HTML Links - Syntax

The HTML <a> tag defines a hyperlink. It has the following syntax:

The most important attribute of the <a> element is the href attribute, which indicates the link's destination.

The link text is the part that will be visible to the reader.

Clicking on the link text, will send the reader to the specified URL address.

Below you can see an example of creating a link to Amazon

By default, links will appear as follows in all browsers:


HTML Links - The target Attribute

By default, the linked page will be displayed in the current browser tab. To change this, you must specify the links target.

The target attribute specifies where to open a linked page.

The target attribute can have one of the following values:

The following example opens Google in a new tab:


Absolute URLs vs. Relative URLs

Both wxamples above use an absolute URL (a full web address) in the href attribute.

A local link (a link to a page within the same website) is specified with a relative URL (without the "https://www" part):


Link to an Email Address

Use mailto: inside the href attribute to create a link that opens the user's email program (to let them send a new email):