HTML Tutorial
HTML Forms
HTML Graphics
HTML Media
HTML API
Html Links
HTML links are defined as hyperlinks.
By clicking on the link, you can jump to another document.
When the mouse is moved over a link, the mouse arrow turns into a small hand.
HTML Links – Syntax
The HTML <a> tag denotes a hyperlink. It has the following syntax:
<a href=”url”>link text</a>
The href attribute is the important part of the <a> element, indicating the link’s destination.
The link text is visible to the reader.
Click the link text, that will take you to the specified URL address.
Example
HTML Links
Output:
HTML Links
Visit mywebhostguru.com!By default, links appear as follows in all browsers:
- An unvisited link is underlined and blue.
- A visited link is underlined and purple.
- An active link is underlined and red.
HTML Links – The target Attribute
By default, the linked page is displayed in the current browser window. If you want to change this, you can specify another target for the link.
The target attribute is used to open the linked document.
The target attribute can have one of the following values:
- _self – Default. The document is opened in the same window/tab as it was clicked
- _blank – The document is opened in a new window or tab
- _parent – The document is opened in the parent frame
- _top – The document is opened in the full body of the window
HTML Links
The target Attribute
Visit W3Schools!
If target="_blank", the link will open in a new browser window or tab.
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 denoted with a relative URL (without the “https://www” part):
Example:
Absolute URLs
Relative URLs
HTML Links – Use an Image as a Link
The <img> tag inside the <a> tag is used to make an image as a link:
Output:
Link to an Email Address
mailto:
inside the href attribute is used to create a link that opens the user’s email program (to let them send a new email):
Link to an Email Address
To create a link that opens in the user's email program (to let them send a new email), use mailto: inside the href attribute:
Output: