
- HTML Home
- HTML Roadmap
- HTML Introduction
- HTML History & Evolution
- HTML Editors
- HTML Basic Tags
- HTML Elements
- HTML Attributes
- HTML Headings
- HTML Paragraphs
- HTML Fonts
- HTML Blocks
- HTML Style Sheet
- HTML Formatting
- HTML Quotations
- HTML - Comments
- HTML - Colors
- HTML - Images
- HTML - Image Map
- HTML - Frames
- HTML - Iframes
- HTML - Phrase Elements
- HTML - Code Elements
- HTML - Meta Tags
- HTML - Classes
- HTML - IDs
- HTML - Backgrounds
- HTML Tables
- HTML - Tables
- HTML - Table Headers & Captions
- HTML - Table Styling
- HTML - Table Colgroup
- HTML - Nested Tables
- HTML Lists
- HTML - Lists
- HTML - Unordered Lists
- HTML - Ordered Lists
- HTML - Definition Lists
- HTML Links
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML Color Names & Values
- HTML - Color Names
- HTML - RGB & RGBA Colors
- HTML - HEX Colors
- HTML - HSL & HSLA Colors
- HTML - HSL Color Picker
- HTML Forms
- HTML - Forms
- HTML - Form Attributes
- HTML - Form Control
- HTML - Input Attributes
- HTML Media
- HTML - Video Element
- HTML - Audio Element
- HTML - Embed Multimedia
- HTML Header
- HTML - Head Element
- HTML - Adding Favicon
- HTML - Javascript
- HTML Layouts
- HTML - Layouts
- HTML - Layout Elements
- HTML - Layout using CSS
- HTML - Responsiveness
- HTML - Symbols
- HTML - Emojis
- HTML - Style Guide
- HTML Graphics
- HTML - SVG
- HTML - Canvas
- HTML APIs
- HTML - Geolocation API
- HTML - Drag & Drop API
- HTML - Web Workers API
- HTML - WebSocket
- HTML - Web Storage
- HTML - Server Sent Events
- HTML Miscellaneous
- HTML - Document Object Model (DOM)
- HTML - MathML
- HTML - Microdata
- HTML - IndexedDB
- HTML - Web Messaging
- HTML - Web CORS
- HTML - Web RTC
- HTML Demo
- HTML - Audio Player
- HTML - Video Player
- HTML - Web slide Desk
- HTML Tools
- HTML - Velocity Draw
- HTML - QR Code
- HTML - Modernizer
- HTML - Validation
- HTML - Color Picker
- HTML References
- HTML - Cheat Sheet
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Character Entities
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
- HTML Resources
- HTML - Quick Guide
- HTML - Useful Resources
- HTML - Color Code Builder
- HTML - Online Editor
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 |