HTML Links
To make a hyperlink in an HTML page, use the <a> and </a> tags, which are the tags used to define the links. The <a>tag indicates where the hyperlink starts and the </a> tag indicates where it ends. Whatever text gets added inside these tags, will work as a hyperlink :
HTML Links - Hyperlinks
HTML links are hyperlinks.
You can click on a link and jump to another document.
When you move the mouse over a link, the mouse arrow will turn into a little hand.
<a href ="url"> link text </a>
Example
<a href ="https://google.com"> Go to the google </a>
example result
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:
_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
<a href="https://www.google.com" target ="_self"> visit Google! </a>
<a href="https://www.google.com" target ="_blank"> visit Google! </a>
<a href="https://www.google.com" target ="_parent"> visit Google! </a>
<a href="https://www.google.com" target ="_top"> visit Google! </a>
Visit google on _blank targeted...
Visit google on _parent targeted...
Visit google on _top targeted...
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:
<a href="https://www.google.com"> Google </a>
<a href="new/index.html"> index file </a>
Image as a Link
To use an image as a link, just put the <img>
tag inside the
<a>
tag:
<a href="https://www.nature.com/">
<img href="image-1.jpg" alt="Image 1">
</a>
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):
<a href="mailto:xyz123@gmail.com">Send Mail</a>