HTML <a> Tag - GeeksforGeeks

17 Mar, 2022
The <a> tag (anchor tag) in HTML is used to create a hyperlink on the webpage. This hyperlink is used to link the webpage to other web pages. It’s either used to provide an absolute reference or a relative reference as its “href” value.
Syntax: 
<a href = "link"> Link Name </a>
Attribute: The anchor tag contains many attributes which are listed below.
HTML <a> charset Attribute: This attribute is used to specifies the character-set. It is not supported by HTML 5.
HTML <a> download Attribute: It is used to specify the target link to download when the user clicks.
HTML <a> hreflang Attribute: It is used to specify the language of the linked document.
HTML <a> media Attribute: It is used to specify the linked media.
HTML <a> coords Attribute: It is used to specify the coordinate of links. It is not supported by HTML 5.
HTML <a> name Attribute: It is used to specify the anchor name. It is not supported by HTML 5 you can use the global id attribute instead.
HTML <a> rel Attribute: It is used to specify the relation between the current document and the linked document.
HTML <a> shape Attribute: It is used to specify the shape of the link. It is not supported by HTML 5.
HTML <a> type Attribute: It is used to specify the type of links.
HTML <a> target Attribute: It specifies the target link.
HTML <a> rev Attribute: It is used to specify the relation between the linked document and the current document. It is not supported by HTML 5.
Example 1: In this example, the GeeksforGeeks HTML Tutorial page will open when you click on the GeeksforGeeks HTML Tutorial link.
HTML
<!DOCTYPE html><html><body>      <h2>Welcome to GeeksforGeeks HTML Tutorial</h2>  <a href="https://www.geeksforgeeks.org/html-tutorials/">     GeeksforGeeks HTML Tutorial  </a>  </body>  </html>
Output:
HTML <a> tag
Example 2: In this example we simply redirect from the GeeksforGeeks to the Geeksforgeeks page.
HTML
<!DOCTYPE html><html>  <body>  <h1>    Welcome to    <a href="https://www.geeksforgeeks.org/">      GeeksforGeeks    </a>  </h1>  <h2>This is anchor Tag</h2></body>  </html>
Output: 
Redirecting the linked text to the site using <a> tag
Example 3: In this example, we will use an image to redirect to the Geeksforgeeks page.
HTML
<!DOCTYPE html><html><body>      <p>Click on the image to open web page.</p>        <!-- anchor tag starts here -->  <a href="https://www.geeksforgeeks.org/">    <img src="https://media.geeksforgeeks.org/wp-content/uploads/gfg1-11.png"     width="300" height="250" />  </a>  <!-- anchor tag ends here --></body>  </html>
Output:
Redirecting the linked image to website using HTML <a> tag
Supported Browsers: 
Google Chrome
Internet Explorer
Firefox
Opera
Safari
Microsoft Edge
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
adhya20kumari
shubhamyadav4
bhaskargeeksforgeeks
vshylaja
HTML-Tags
Picked
HTML
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to insert spaces/tabs in text using HTML/CSS?
How to set the default value for an HTML <select> element ?
How to update Node.js and NPM to next version ?
How to set input type date in dd-mm-yyyy format using HTML ?
Hide or show elements in HTML using display property
Types of CSS (Cascading Style Sheet)
How to Insert Form Data into Database using PHP ?
CSS to put icon inside an input element in a form
REST API (Introduction)