Horje
HTML Text Links

HTML links are defined with the <a> tag.


Example of HTML Links

Following is example of HTML Text Link

index.html
Example: HTML
<a href="https://horje.com">
This is a link</a>

Output should be:

Example of HTML Links

Definition of HTML Text Link

An HTML text link, also known as a hyperlink, is a clickable piece of text on a web page that, when activated, directs the user to another web page, a specific section within the same page, or another online resource. It is a fundamental element of the World Wide Web, enabling navigation and connection between various online content.
 
HTML text links are created using the <a> (anchor) tag, with the href attribute specifying the destination URL.

HTML Links - 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.

The target attribute specifies where to open the linked document.

The target attribute can have one of the following values:

index.html
Example: HTML
<a href="https://horje.com" target="_blank">Visit Horje!</a>

Output should be:

HTML Links - The target Attribute

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).

index.html
Example: HTML
<h2>Absolute URLs</h2>
<p><a href="https://www.w3.org/" target="_blank">W3C</a></p>
<p><a href="https://www.google.com/" target="_blank">Google</a></p>
<h2>Relative URLs</h2>
<p><a href="html_images.asp">HTML Images</a></p>
<p><a href="/css/default.asp">CSS Tutorial</a></p>

Output should be:

Absolute URLs vs. Relative URLs

HTML Links - Use an Image as a Link

To use an image as a link, just put the <img> tag inside the <a> tag.

index.html
Example: HTML
<a href="https://horje.com/avatar.png">
<img src="https://horje.com/avatar.png" alt="HTML tutorial" style="width:42px;height:42px;">
</a>

Output should be:

HTML Links - Use an Image as a Link

HTML 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):

index.html
Example: HTML
<a href="mailto:[email protected]">
Send email</a>

Output should be:

HTML Link to an Email Address

HTML Button as a Link

To use an HTML button as a link, you have to add some JavaScript code.

JavaScript allows you to specify what happens at certain events, such as a click of a button.

index.html
Example: HTML
<button onclick="document.location='default.asp'">
HTML Tutorial</button>

Output should be:

HTML Button as a Link

HTML Link Titles

The title attribute specifies extra information about an element. The information is most often shown as a tooltip text when the mouse moves over the element.

index.html
Example: HTML
<a href="https://horje.com" title="Go to Horje HTML section">Visit our HTML Tutorial</a>

Output should be:

HTML Link Titles

HTML Absolute URLs

It means a full URL to link to a web page.

index.html
Example: HTML
<a href="https:/horje.com">HTML tutorial</a>

Output should be:

HTML Absolute URLs

HTML Relative URLs

It means Link to a page located in the html folder on the current web site

index.html
Example: HTML
<a href="/html/default.asp">HTML tutorial</a>

Output should be:

HTML Relative URLs

Chapter Summary of HTML Links






Related Articles
HTML Documents HTML Basic
HTML <!DOCTYPE> Declaration HTML Basic
HTML Headings HTML Basic
HTML Paragraphs HTML Basic
HTML Text Links HTML Basic
HTML Images HTML Basic
How to View HTML Source HTML Basic

Single Articles
Example of HTML Links HTML Basic
Definition of HTML Text Link HTML Basic
HTML Links - The target Attribute HTML Basic
Absolute URLs vs. Relative URLs HTML Basic
HTML Links - Use an Image as a Link HTML Basic
HTML Link to an Email Address HTML Basic
HTML Button as a Link HTML Basic
HTML Link Titles HTML Basic
HTML Absolute URLs HTML Basic
HTML Relative URLs HTML Basic
Chapter Summary of HTML Links HTML Basic

Category :
Web Tutorial
Sub Category :
HTML Basic
Uploaded by :
Admin


Read Article
https://horje.com/learn/1434/reference