<a>
Published Jul 1, 2022
Contribute to Docs
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 thehref
.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"><imgsrc="https://raw.githubusercontent.com/Codecademy/docs/main/media/cc_logo.png"/></a></li><!-- Email and Phone Links --><li><a href="tel:234-555-1212">234-555-1212</a></li></ul>
The rendered output would look like this:
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.