<a>

The <a> element, also known as the “anchor” element, creates a link to another page or to a location in the current page. It can also be used to link to email addresses, phone numbers, and files.

Syntax

<a href="url">Displayed Text</a>

The following attributes are commonly used in the <a> element:

  • href, which represents the URL that the link points to.
  • target, which represents where to open and display the URL stored in the href.
  • rel, which describes the link type of for the element (e.g., using "noopener" and "noreferrer" when adding browser safeguards to links).

Example

The following example shows a list of links that utilize the <a> element:

<ul>
<!-- External Link -->
<li>
<a href="https://codecademy.com" target="_blank" rel="noreferrer noopener"
>Codecademy</a
>
</li>
<!-- Internal Link -->
<li><a href="#about-us">About Us</a></li>
<!-- Image Link -->
<li>
<a href="http://www.codecademy.com">
<img
src="https://raw.githubusercontent.com/Codecademy/docs/main/media/cc_logo.png"
/></a>
</li>
<!-- Email and Phone Links -->
<li><a href="mailto:[email protected]">[email protected]</a></li>
<li><a href="tel:234-555-1212">234-555-1212</a></li>
</ul>

The rendered output would look like this:

Rendered anchor tags

Edit this page on GitHub

Contributors

Interested in helping build Docs? Read the Contribution Guide or share your feedback form.

Learn HTML on Codecademy