Link Tag in HTML: Anchor vs Link Element Explained

November 11, 2026 · 10 min read

Link Tag in HTML: How the Anchor Tag Creates Hyperlinks

A link tag in HTML means one of two elements. The anchor element, <a href>, creates the clickable hyperlinks people see on a page. The <link> element sits in <head> and connects the page to resources such as stylesheets and icons, and it renders nothing you can click. This page covers both, anchor first.

What Is a Link Tag in HTML? <a> vs <link>

If you want text someone can click, you want the anchor tag. If you're attaching a CSS file or a favicon, you want the <link> element. Both use href and rel, which is why people mix them up, but they do very different jobs.

<a> (anchor)<link>
What it doesCreates a clickable hyperlinkConnects the document to an outside resource
Where it goesIn <body>, usually inside textIn <head> (a few rel values may sit in the body)
Visible on the pageYes, its content is the link textNo
Closing tagRequired: </a>None, it's a void element
Main attributeshref, target, rel, downloadrel (required), href
Typical rel valuesnoopener, noreferrer, nofollow, sponsored, ugcstylesheet, icon, preload, canonical, alternate

So the HTML tag for links you click is <a>. The rest of this page is a reference for it, with a short section on <link> at the end.

HTML Anchor Tag Syntax: href and Link Text

An HTML anchor tag needs two things: an href with the destination and some content to click. Everything between <a> and </a> becomes the clickable area.

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

This renders the words MDN Web Docs as a link to the MDN homepage. The href value can take several forms:

<a href="https://example.com/pricing">Pricing on another site</a>
<a href="/docs/install">Install guide on this site</a>
<a href="setup.html">A file in the same folder</a>
<a href="#faq">The FAQ section on this page</a>

The first is absolute, the next two are relative, and the last is a fragment. A common bug is href="www.example.com" with no https://. The browser resolves it against the current page's URL, so the link points to a path called www.example.com on your own site. A fragment like #faq jumps to the element whose id is faq on the same page. Our guide to the HTML internal link covers the id rules and the fixes for jumps that fail.

Other attributes are optional. hreflang hints at the target's language, type at its file type, and referrerpolicy controls how much of your URL the destination receives. Most browsers show unvisited links blue and underlined and visited ones purple until your CSS styles the :link, :visited, :hover and :focus-visible states.

Two content rules catch people out. Per the HTML standard, an anchor without href is only a placeholder: it isn't focusable and doesn't count as a link. And as MDN's reference for the a element lists, an anchor can't contain interactive content, so no buttons and no second <a> inside it. It can wrap an image or a whole card of text, though. Our guide to making a clickable image link covers the alt text and CSS fixes.

How Do You Open a Link in a New Tab?

Add target="_blank" to the anchor tag. The target attribute names where the link opens, and it takes these keywords:

  • _self opens in the current tab. This is the default.
  • _blank opens a new tab, or a new window if the user set their browser that way.
  • _parent opens in the parent frame, or acts like _self when there isn't one.
  • _top opens in the topmost frame, which breaks out of nested iframes.
  • Any other name targets the frame or window with that name, and the browser opens a new one if none exists.
<a href="https://example.com/help" target="_blank" rel="noopener noreferrer">
  Help (opens in a new tab)
</a>

The rel="noopener" part matters for security. Without it, older browsers gave the new page a window.opener reference back to yours, which a hostile page could use to redirect your tab. MDN notes that target="_blank" now implies the same behaviour as noopener. We still write it out, because it states the intent and covers older browsers.

We prefer leaving most links in the same tab. People know how to open a new tab themselves. Reserve _blank for links that would interrupt a task, such as a help page linked from inside a half-filled form.

rel Values for an HTML Hyperlink Tag: nofollow, sponsored and ugc

The rel attribute describes how the current page relates to the linked one. It takes a space-separated list, so rel="noopener nofollow" is valid.

These values make sense on an anchor:

ValueWhat it tells the browser or search engine
noopenerDon't give the new page access to window.opener
noreferrerDon't send the Referer header (it also implies noopener)
nofollowYou don't endorse the linked page, and you'd rather search engines not follow it
sponsoredThe link is an ad or paid placement
ugcThe link sits in user-generated content, such as comments
externalThe link leads to a different site

The sponsored and ugc values come from Google's guidance on qualifying outbound links. Google says you can combine them, as in rel="ugc nofollow". It also says nofollow is still acceptable for paid links, though sponsored is preferred.

Values like nofollow and noopener belong on anchors (and <area> and <form>). The HTML standard doesn't allow them on <link> at all.

Email, Phone and Download Links

An href isn't limited to web pages. Browsers hand other URL schemes to the right app, and the download attribute changes what a click does.

<a href="mailto:hello@example.com?subject=Order%20question&body=Hi%20there">Email support</a>
<a href="tel:+1-201-555-0123">Call +1 201 555 0123</a>
<a href="/files/q3-report.pdf" download="q3-report.pdf">Download the Q3 report (PDF)</a>

A mailto: link opens a new message in the visitor's mail app with the subject and body filled in. RFC 6068 defines the format: separate fields with &, percent-encode spaces as %20, and separate several recipients with commas.

The tel: link opens the dialer on phones. On desktops it opens whatever app handles calls, if one is set up. Write the number in international form with a leading +, as RFC 3966 does in its own examples.

Adding download asks the browser to save the file instead of opening it, and its value suggests a filename. It only works for same-origin URLs, same-origin blob: URLs and data: URLs. On a link to another origin, the browser ignores it and navigates normally, though that server can still force a download with a Content-Disposition header.

Writing Accessible Link Text for the Anchor Tag

Link text should make sense on its own. Screen reader users often pull up a list of every link on a page, and ten links that all say click here tell them nothing. WCAG 2.2 success criterion 2.4.4, Link Purpose (In Context), is a Level A requirement, so even the most basic conformance target includes it.

<a href="/pricing">Click here</a> to see our plans.
See the <a href="/pricing">pricing plans</a>.

The first line is vague out of context. The second tells you where the link goes before you follow it.

Use aria-label only when the visible text truly can't carry the meaning, such as an icon-only link. Keep the visible words at the start of the label so voice-control users can still say them.

Here's the limitation: HTML has no attribute that tells people a link opens a new tab or downloads a file. You have to say it yourself, in the link text or with an icon that has a text alternative. MDN recommends doing exactly that for _blank and download links.

One more rule: use an anchor for navigation and a <button> for actions. If you want a link that looks like a button, our guide to the Markdown button covers the styling.

How Markdown Links Become Anchor Tags

Every Markdown link compiles to an anchor. [MDN](https://developer.mozilla.org/ "Docs") becomes <a href="https://developer.mozilla.org/" title="Docs">MDN</a>, and in GFM a bare URL turns into an anchor with the URL as its text. The full Markdown syntax, including reference links, is in our Markdown links guide.

Standard Markdown (CommonMark and GFM) has no syntax for target, rel or download. When you need them, write the raw anchor tag in your Markdown, on platforms that allow inline HTML.

Edit the demo below, then click Export HTML. The right pane shows the generated HTML, with each link turned into an anchor tag and the raw anchor's target and rel left intact.

Links in Markdown and HTML

A Markdown link: MDN on the a element

A link with a title: WHATWG HTML

An autolink: https://example.com

An email link: Email us

Raw HTML for a new tab:
<a href='https://example.com' target='_blank' rel='noopener noreferrer'>Opens in a new tab</a>

47 words449 characters12 lines
Markdown

In the main editor, Ctrl+K (Cmd+K on a Mac) inserts the Markdown link syntax for you. For other ways to turn a whole file into HTML, see how to convert Markdown to HTML.

The <link> Element in head: Stylesheets, Icons and Preload

The other link tag in HTML lives in <head> and wires up resources the page needs. It has no content and no closing tag, and it must carry a rel attribute. It's one of the 13 void elements listed in our guide to tags in HTML.

<head>
  <link rel="stylesheet" href="/styles/main.css">
  <link rel="icon" href="/favicon.ico">
  <link rel="preload" href="/fonts/inter.woff2" as="font" type="font/woff2" crossorigin>
  <link rel="canonical" href="https://example.com/guide/">
</head>

These lines load a stylesheet, set the tab icon, start fetching a font early, and name the preferred URL for search engines. Nothing appears on the page itself. A preload needs as to say what kind of file it is, and font preloads need crossorigin.

A few rel values may also appear in <body>, according to the HTML standard's link types. These include stylesheet, preload, prefetch and preconnect. Others, such as icon and canonical, belong in <head> only.

The link tag in HTML that people click is always the anchor, while <link> quietly loads resources in the head. Once you've picked the right element, the rest is attributes: href for the destination, target and rel for behaviour, and clear text for people. Write your links in Markdown, then run them through the Markdown to HTML converter to check the anchor tags it produces before you paste them into a page.