<a> Tag in HTML

Quick facts

CategoryFlow content, phrasing content, interactive content, palpable content
Content modelTransparent — can contain any content except another <a>, when href is present
Tag omissionNeither the start nor end tag can be omitted
Permitted parentsAny element that accepts phrasing content
DOM interfaceHTMLAnchorElement

Syntax

<a href="https://example.com">link text</a>

Live example

Edit the code below and watch the preview update instantly.

index.html
Preview

Attributes

AttributeDescription
hrefThe link’s destination — a URL, an in-page anchor (#id), a mailto:, or a tel: link
targetWhere to open the link — e.g. _blank for a new tab
relRelationship to the linked resource — commonly noopener or nofollow
downloadPrompts the browser to download the linked file instead of navigating to it
titleExtra advisory text, usually shown as a tooltip on hover

Common examples

Link to another page

Use a relative URL for pages on your own site and a full absolute URL for other websites.

<a href="/about/">About us</a> <a href="https://developer.mozilla.org/">MDN Web Docs</a>

Email and phone links

The mailto: and tel: schemes open the visitor’s email app or phone dialer.

<a href="mailto:hello@example.com">Email us</a> <a href="tel:+15550100">Call +1 555 0100</a>

Jump to a section on the same page

Give the target an id, then link to it with # followed by that id — great for tables of contents and “back to top” links.

<a href="#pricing">See pricing</a> <h2 id="pricing">Pricing</h2>

<a> vs <button>

This is one of the most common HTML questions, and the rule is simple: links go somewhere, buttons do something. Use <a href> when clicking takes the visitor to another page, file or section. Use a <button> when clicking performs an action on the current page, such as submitting a form, opening a menu or playing a video.

Getting this right matters for accessibility: screen readers announce links and buttons differently, and keyboard users expect Enter to follow a link but Space or Enter to press a button. It also matters for SEO, because only real links with an href pass ranking signals between pages.

<a href><button>
PurposeNavigate to a URLRun an action
KeyboardEnterEnter or Space
Followed by search enginesYesNo

Common mistakes to avoid

  • “Click here” link text. Vague text tells nobody where the link goes. Describe the destination: “Download the 2026 price list”.
  • Using a link as a button. If clicking runs an action (open a menu, submit data) rather than going somewhere, use a <button>.
  • Broken relative paths. about.html and /about.html point to different places; test links after moving files.
  • Nesting a link inside another link. It’s invalid HTML and browsers split the links unpredictably.

Accessibility & SEO tips

  • Descriptive anchor text is one of the clearest signals search engines use to understand what the linked page is about — and it helps screen reader users who browse a list of links.
  • Mark paid or untrusted links with rel="sponsored" or rel="nofollow", as Google recommends.
  • Avoid opening links in new tabs unless there’s a good reason; if you do, say so in the link text, e.g. “(opens in new tab)”.
  • Keep a visible focus style (outline) so keyboard users can see which link is selected.

Browser support

Supported in every browser, including Chrome, Edge, Firefox, Safari and their mobile versions — it has been part of HTML since the very first versions.

Related tags

Frequently asked questions

How do I open a link in a new tab?
Add target="_blank", and pair it with rel="noopener" so the new tab can't access the original page for security reasons.
Can I use <a> for a button-like action instead of navigation?
Prefer <button> for actions that don't navigate anywhere, like toggling a menu or submitting a form. Use <a> only when there's a real destination URL.
What is the difference between an absolute and a relative URL?
An absolute URL includes the full address, such as https://example.com/about/. A relative URL like /about/ is resolved against the current site, so it keeps working if your domain changes. Use relative URLs for your own pages.
How do I remove the underline from a link?
Use CSS: a { text-decoration: none; }. Keep links visually distinct some other way, such as color or bold, so visitors can still tell them apart from normal text.
What does rel="nofollow" do?
It tells search engines not to pass ranking credit to the linked page. Use it, or rel="sponsored" for paid links and rel="ugc" for user comments, on links you don't want to vouch for.