Dear readers, welcome to the chapter 7 of our HTML Tutorial series. In the previous chapter, we wrote about using Comments in HTML. In this chapter we shall explore what are Hyperlinks in HTML and how can we add them into a Web page.
If you go to any website, let’s say www.123mylist.com, if you click on any of the placeholder text given on the top navigation bar, you will get redirected to another page. These are nothing but HTML Hyperlinks, also known as HTML Links.
An HTML Link helps the user to navigate to another page in the same website or an external website upon clicking a web element which is linked to the target URL.
To add a Hyperlink within an HTML document, you can use the following syntax:
Syntax:
HTML:
<a href="https://www.example.com/page1">Go to new Website</a>
You can try running this code snippet on our Online HTML Editor to view the output.
Here,
Href Attribute:
As explained above, the “href” attribute contains the target URL where we want to redirect our user on clicking the Link text.
You can provide URLs in the HREF attribute in multiple ways
<a href=”/folder/sub-page.php”>Relative URL Demo</a>
<a href="mailto:hello@123mylist.com">Contact me</a>
Target Attribute:
The anchor tag supports an optional attribute called “target”. This attribute denotes where the target URL shall be displayed on the browser.
The syntax to use this attribute is given below:
HTML:<a href=”https://www.example.com/page1” target=”_blank”>Go to new Website</a>
Some of the commonly used values for this attribute are given below for reference:
Title Attribute:
Sometimes you might have noticed that when you do mouse hover over the link text, you get to see some helpful messages for the user. These are called tooltips. If you want to add such tooltips over your link text, you can make use of the title tag.
The syntax for using title attribute is given for reference.
HTML:
<a href="https://www.example.com/page1" title="This is tooltip message">Go to new Website</a>
Here, you can enclose custom plain text messages within the value of the “title” attribute in order to display them as tooltips.
I hope you liked reading this tutorial. Do share among your friends and circles.
See you soon in the next tutorial.
Next Chapter Chapter 8 - HTML Images
Fully customizable CRM Software for Freelancers and Small Businesses