HTML Links - Hyperlinks
HTML links are hyperlinks. You can click on a link and jump to another document.
HTML Links Syntax
The HTML <a> tag defines a hyperlink. It has the following syntax:
<a href="url">link text</a>The most important attribute of the <a> element is the href attribute, which indicates the link's destination.
Example
<a href="https://www.smalseotool.com">Visit Smal SEO Tool!</a>The target Attribute
By default, the linked page will be displayed in the current browser window. To change this, you must specify another target for the link using the target attribute.
_self- Default. Opens the document in the same window/tab as it was clicked._blank- Opens the document in a new window or tab._parent- Opens the document in the parent frame._top- Opens the document in the full body of the window.
Example: target="_blank"
<a href="https://www.smalseotool.com" target="_blank">Visit Smal SEO Tool!</a>Absolute URLs vs. Relative URLs
Both examples above are using 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).
Example: Absolute vs Relative
<p><a href="https://www.google.com/">Google</a></p><p><a href="/html/html-images.html">HTML Images</a></p>HTML Links - Use an Image as a Link
To use an image as a link, just put the <img> tag inside the <a> tag.
Example
<a href="default.asp">
<img src="smiley.gif" alt="HTML tutorial" style="width:42px;height:42px;">
</a>Link to an Email Address
Use mailto: inside the href attribute to create a link that opens the user's email program.
Example
<a href="mailto:someone@example.com">Send email</a>Test Yourself with an Exercise
Which attribute specifies the destination of an HTML link?