There are links on almost every web page called HTML hyperlinks. Links enable visitors to navigate between pages by clicking.
HTML Links – Hyperlinks
Hyperlinks are links in HTML.
You can access another paper by clicking on a link.
The mouse arrow will change into a tiny hand when you move the mouse pointer over a link.
Links in HTML – Syntax
A hyperlink is defined by the HTML a> tag. Its syntax is as follows:
<a href=”link_url“>text</a>
It has the ability to build links to other websites, files, locations, or any URL. The HTML a tag’s “href” attribute is its most crucial component. and which points to the URL or target page.
HTML Links – The href Attribute
The href attribute of the a> element, which denotes the location of the link, is its most crucial component.
The portion that the reader will see is the link text.
The reader will be directed to the provided URL address by clicking on the link text.
<a href=”https://www.coderazaa.com/”>Visit coderazaa.com!</a>
HTML Links – The target Attribute
The address of the file to be linked is specified using the href property. Or put another way, it identifies the final page.
Here is a list of the HTML anchor tag’s syntax.
<a href=”https://www.coderazaa.com/” target=”_blank”>Visit coderazaa!</a>
The linked page will by default open in the current browser tab. You must specify a different target for the link in order to change this.
Where to open the linked document is specified by the target attribute.
One of the following values may be present for the target attribute:
Opens the document in the same window or tab as it was clicked by _self, _blank, _parent, _top.
The target
attribute can have one of the following values:
_self
– Default. opens the file in the same tab or window as it was originally clicked._blank
– opens the file in a new tab or window._parent
– the document is displayed in the parent frame._top
– opens the file in the window’s main body.
Comparing absolute and relative URLs
In the two aforementioned cases, the href property is used with an absolute URL (a complete web address).
A relative URL (without the “https://www” element) is used to specify a local link, which is a link to a page within the same website:
<h2>Absolute URLs</h2>
<p><a href=”https://www.coderazaa.com/”>coderazaa</a></p>
<p><a href=”https://www.google.com/”>Google</a></p><h2>Relative URLs</h2>
<p><a href=”html_class.php”>HTML Tutorial</a></p>
<p><a href=”/css/index.php”>CSS Tutorial</a></p>
Image as a link in HTML
Use the <img> tag inside the a> tag to use an image as a link:
<a href=”index.php”>
<img src=”image.png” alt=”Link tutorial” style=”width:42px;height:42px;”>
</a>
Link to an email address
To create a link that launches the user’s email client and allows them to send a new email, use the mailto: attribute inside the href attribute:
<a href=”mailto:example@example.com”>Test email</a>
Button Link
You must include some JavaScript code in order to use an HTML button as a link.
JavaScript enables you to define what happens in response to specific events, such the click of a button:
<button onclick=”document.location=’index.php'”>HTML Tutorial</button>
Link Titles
An element’s title attribute specifies additional information. When the mouse is over the element, the information is frequently displayed as a tooltip text.
<a href=”https://www.coderazaa.com/html/” title=”coderazaa HTML “>Visit coderazaa HTML Tutorial</a>
HTML Link <a> Overview
- Create a link using the <a> element.
- To specify the link address, use the href attribute.
- To specify where to open the linked page, use the target attribute.
- To utilise an image as a link, use it inside the img> element of an <a>.
- To construct a link that launches the user’s email software, use the mailto: scheme inside the href element.