In HTML, the
<a> tag is used to create links. The
<a> tag is an anchor tag, and it has an href attribute that specifies the URL of the resource that the link points to.
Here’s an example of an
<a> tag used to create a link:
<a href="https://www.example.com">Visit Example.com</a>
In this example, the
href attribute specifies the URL of the website that the link points to, and the text between the opening and closing
<a> tags is the link text that the user clicks on.
<a> tag can also be used to create links to other resources such as email addresses, phone numbers, or other web pages on the same site. To create a link to an email address, you can use the
mailto: protocol in the
href attribute. Here’s an example:
<a href="mailto:email@example.com">Send an email to Example</a>
In this example, clicking the link will open the user’s default email client with a new message addressed to “firstname.lastname@example.org”.
<a> tag can also be used to create links to other parts of the same web page using the
id attribute. Here’s an example:
<a href="#section-2">Jump to Section 2</a> ... <h2 id="section-2">Section 2</h2>
In this example, clicking the link will jump the user to the section of the web page with the
id attribute “section-2”.