HTML - <a> Tag
The HTML <a> tag (anchor tag) is used to create hyperlinks, to navigate between different webpages or sections within the page. It creates clickable text, images allowing users to visit external websites or download files.
The primary attribute of the <a> tag is href, which specifies the links destination. Additional attributes like target control the link destination.
Syntax
Following is the syntax of HTML <a> tag −.
<a href="...">Content...</a>
Attributes
HTML a tag supports Global and Event attributes of HTML. Accept some specific attributes as well which are listed bellow.
| Attribute | Value | Description |
|---|---|---|
| download | filename | Allow user to download the linked file when user clicked on the hyperlink. |
| href | URL | Specify the link page where we wants to send the user. |
| hreflang | language_code | Spefeicy the language of the attached link. |
| media | media_query | Specifies what media/device the linked document is optimized for. |
| ping | list_of_URLs | Specifies a space-separated list of URLs. |
| referrerpolicy | no-referrer no-referrer-when-downgrade origin origin-when-cross-origin same-origin strict-origin-when-cross-origin unsafe-url |
Specifies which referrer information to send with the link. |
| rel | alternate author bookmark external help license next nofollow noreferrer noopener prev search tag |
Define the relation between the current and linked url document. |
| target | _blank _parent _self _top |
Specify how or where to open the linked document. |
| type | media_type | Specify the media type of the inked url document. |
Example : Basic Hyperlink
In the following example, we are going to consider the basic usage of the <a> tag.
<!DOCTYPE html>
<html>
<body>
<p><a href="https://www.tutorialspoint.com/index.htm">Home Page</a>
</p>
</body>
</html>
Example : Opening Link in a New Tab
Consider the following example, where we are going to use the target="_blank" attribute to open the link in the new window.
<!DOCTYPE html>
<html>
<body>
<a href=https://www.tutorialspoint.com/index.htm target="_blank" name=tutorialspoint>
TutorialsPoint
</a>
</body>
</html>
Example : Linking to an Email Address & Mobile
Let's look at the following example, where we are going to use the <a> tag to create a hyperlinks for the email and mobile number.
<!DOCTYPE html>
<html>
<body>
<p>You can contact with us</p>
<ul>
<li><a href="tel:+910000000" name=Call>
Call Us
</a></li>
<li><a href="mailto:example@xyz.com" name=Mail>
Mail Us
</a></li>
</ul>
</body>
</html>
Example : Anchor Link Within a Page
Following is the example, where we are creating the hyperlinks within the page.
<!DOCTYPE html>
<html>
<style>
div {
margin-top: 1500px;
border: 1px solid black;
}
</style>
<body>
<a href="#section1">Go to Section 1</a>
<br>
<a href="#section2">Go to Section 2</a>
<div>
<h2 id="section1">Section 1</h2>
</div>
<div>
<h2 id="section2">Section 2</h2>
</div>
</body>
</html>
Example : Downloading the File
In the following example, we are going to use the download attribute with the <a> tag to download the file.
<!DOCTYPE html>
<html>
<body>
<div>
<p>
Click the
<a href="https://www.tutorialspoint.com/images/logo.png" name=image download>
Download
</a> Button
</p>
</div>
</body>
</html>
Supported Browsers
| Tag | ![]() |
![]() |
![]() |
![]() |
![]() |
|---|---|---|---|---|---|
| a | Yes | Yes | Yes | Yes | Yes |




