<a>)š The anchor tag is one of the most important tags in HTML. It is used to create hyperlinks that allow users to navigate between web pages, sections of a page, email, phone numbers, or even download files.
Basic Syntax:
<a href="URL">Link Text</a>
<a> ā opening tag (anchor)href ā attribute that tells the browser where to goLink Text ā clickable text (anchor text)</a> ā closing tag<a> TagThe anchor tag comes with several attributes that control its behavior.
href (Hypertext Examples:
<a href="https://www.cbse.gov.in">CBSE Website</a>
<!-- External -->
<a href="about.html">About Us</a>
<!-- Internal -->
<a href="#top">Go to Top</a>
<!-- Bookmark -->
targetValues:
_self ā Opens in the same tab (default)._blank ā Opens in a new tab/window._parent ā Opens in the parent frame (used with frames)._top ā Opens in the full body of the window.Example:
<a href="https://www.cbse.gov.in" target="_blank">Open CBSE in New Tab</a>
titleExample:
<a href="contact.html" title="Get in touch with us">Contact Us</a>
downloadExample:
<a href="notes.pdf" download>Download Notes</a>
name / id (used for Bookmarks)Example:
<h2 id="section1">Introduction</h2>
<a href="#section1">Go to Introduction</a>
rel (Relationship Attribute)Defines the relationship between the current page and the linked page.
Common values:
nofollow ā tells search engines not to follow this link.noopener / noreferrer ā for security when using target="_blank".Example:
<a href="https://example.com" target="_blank" rel="noopener">Secure Link</a>
href="mailto:" and href="tel:"Examples:
<a href="mailto:teacher@example.com">Email Teacher</a>
<a href="tel:+919876543210">Call Us</a>
<!DOCTYPE html>
<html>
<head>
<title>Anchor Tag Example</title>
</head>
<body>
<!-- External Link -->
<a
href="https://www.cbse.gov.in"
target="_blank"
title="Go to CBSE Official Website"
>Visit CBSE Website</a
><br />
<!-- Internal Link -->
<a href="about.html" title="Learn more about us">About Us</a><br />
<!-- Bookmark Link -->
<a href="#bottom">Go to Bottom of Page</a><br />
<!-- Email and Phone Links -->
<a href="mailto:teacher@example.com">Email Teacher</a><br />
<a href="tel:+919876543210">Call Us</a><br />
<!-- Download Link -->
<a href="notes.pdf" download>Download Notes</a><br />
<p style="margin-top:500px;"></p>
<h2 id="bottom">Bottom Section</h2>
<a href="#top">Go to Top</a>
</body>
</html>
<a> tag = used to create hyperlinks.
Important attributes:
href ā destinationtarget ā where to opentitle ā tooltip infodownload ā for downloading filesid/name ā for bookmarksrel ā relationship/securitymailto: / tel: ā for email and phoneš In short, the anchor tag is like the glue of the internet, connecting documents, websites, and resources together.