In this chapter, we will learn how to use an anchor <a> tag in HTML. It is used to create hyperlink text.

The anchor tags <a> are commonly used to link the separate webpage. Also, they can be used to link between the different website pages on a page.

This chapter is a part of the Complete HTML Tutorial. If you want to learn HTML from scratch, feel free to follow the Tutorial chapter-wise.


How to use anchor tag <a>

The <a> element defines the hyperlink in HTML. It is clickable and redirects you to another page.

Example:

<a href="https://fokatguru.in"> Click to Visit FokatGuru</a>

It creates a hyperlink that is clickable and redirects you to the address specified by the href attribute i.e fokatguru.in

The hyperlink created by the <a> element is applied to the text, images or any other nested elements.

To create a link that will open in a new tab.

<a href="https://fokatguru.in" target="_blank">Click Here</a>

Even, you can specify that the link leads to an external website.

<a href="https://fokatguru.com" rel="external" >External Link</a>
Note: Anchor Tag is an inline element meaning that it will take the width as that of content.

Use an anchor tag like a pro:

You can also link a website that uses an FTP protocol. You can link like this:

<a href="ftp://example.com"> A link to a FTP website</a>

Read more about HTML Links: HTML Links and their uses


How to create a hyperlink with a relative address path

You can also use a relative path if your file exists in the same project or same website.

For example:

 You want to link a photo(myPic.gif) that exists in the Images folder in the root folder.

 <a href="/Images/myPic.gif">Click here</a>

The above link is the same as:

<a href="https://example.com/Images/myPic.gif" >Click Here</a>

Browser Support

The anchor tag <a> is supported by all modern browsers. Feel free to use it.

BrowsersChromeMozilla FirefoxSafari (for Mac)Microsoft EdgeOpera
SupportYesYesYesYesYes

That’s all about the anchor tag <a> in HTML. If you liked this chapter, feel free to connect with us on Youtube for Video Tutorial.


Reminder

We are covering each and every topic of the HTML. Help us to reach other people like you, Kindly do a google search:

  1. fokatguru.in

Keep learning bravo! Good Luck

2022-08-01

Share your feedback

This site uses Akismet to reduce spam. Learn how your comment data is processed.