![]() |
HTML links are defined with the |
Following is example of HTML Text Link
Example:
HTML
<a href="https://horje.com">
This is a link</a>
<a>
(anchor) tag, with the
href
attribute specifying the destination URL.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:
_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:
HTML
<a href="https://horje.com" target="_blank">Visit Horje!</a>
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:
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>
To use an image as a link, just put the
<img>
tag inside the
<a>
tag.
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>
Use
mailto:
inside the
href
attribute to create a link that opens the user's email program (to let them send a new email):
Example:
HTML
<a href="mailto:[email protected]">
Send email</a>
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.
Example:
HTML
<button onclick="document.location='default.asp'">
HTML Tutorial</button>
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.
Example:
HTML
<a href="https://horje.com" title="Go to Horje HTML section">Visit our HTML Tutorial</a>
It means a full URL to link to a web page.
Example:
HTML
<a href="https:/horje.com">HTML tutorial</a>
It means Link to a page located in the html folder on the current web site
Example:
HTML
<a href="/html/default.asp">HTML tutorial</a>
<a>
element to define a link
href
attribute to define the link address
target
attribute to define where to open the linked document
<img>
element (inside
<a>
) to use an image as a link
mailto:
scheme inside the
href
attribute to create a link that opens the user's email programHTML 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 |
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