Skip to content

<a> - The Anchor Element

Inline HTML 1.0

The anchor element creates a hyperlink to web pages, files, email addresses, phone numbers, or locations within the same page.

Result
<a href="url">Link text</a>

The href attribute specifies where the link goes. The content between the tags becomes the clickable link text.

AttributeDescriptionValues
hrefURL the link points toURL, #id, mailto:, tel:
targetWhere to open the link_self, _blank, _parent, _top
relRelationship to linked pagenoopener, noreferrer, nofollow, etc.
downloadDownload instead of navigatingOptional filename
AttributeDescriptionValues
hreflangLanguage of linked resourceLanguage code (e.g., en, es)
typeMIME type of linked resourceMIME type
pingURLs to ping when clickedSpace-separated URLs
referrerpolicyReferrer information to sendno-referrer, origin, etc.
Result

Use target="_blank" with security attributes:

Result

Link to an element with a specific id:

Result
Result
Result
Result
Result
<a href="/pricing">View pricing plans</a>
<a href="/docs">Read the documentation</a>

Screen reader users often navigate by links alone, so “click here” out of context is meaningless.

Let users know when links open new windows:

<a href="https://external.com" target="_blank" rel="noopener">
External Site (opens in new tab)
</a>

Users navigating by keyboard need to see which link is focused. Style focus states, don’t remove them:

a:focus {
outline: 2px solid blue;
outline-offset: 2px;
}
BrowserVersionNotes
Chrome1+Full support
Firefox1+Full support
Safari1+Full support
Edge12+Full support
IE3+Full support

The <a> element has been supported since the earliest browsers.