BF50 Black Friday · 50% off all plans
from $5/mo · Auto-applied ---:--:-- Claim 50% off →
Skip to content

Search Seonio

Type a keyword, domain, or paste a URL

Start free with $1 to see full results. Powered by Seonio
Web Development

Anchor tag: How the HTML a element makes links

The anchor tag is the HTML a element. With an href, it links to another page, a spot on the same page, an email address, a phone number or a file.

Monthly searches · anchor tag
27.1k
Keyword research data
anchor tag
Anchor tag: How the HTML a element makes links
Click the image to view it full size

Most links you click on a web page are built from the same piece of HTML: the <a> element, short for anchor. Give it an href attribute and it becomes a link:

<a href="https://example.com/pricing">See our prices</a>

Each part has a job. The href holds the destination. The words between the opening and closing tags are the anchor text: what people click, and what tells them where they'll land. Without an href, an <a> isn't a link at all; browsers and screen readers treat it as plain text.

In everyday use, "anchor tag" and hyperlink often mean the same thing.

The href takes any URL the browser understands, so one element covers many kinds of links:

To link to Write
A page on another site <a href="https://example.org/guide">
A page on your own site <a href="pricing.html"> (a relative URL)
A section of the same page <a href="#shipping">, which jumps to the element with id="shipping"
The top of the page <a href="#top">
An email address <a href="mailto:[email protected]">
A phone number <a href="tel:+15550100">
A file to download <a href="menu.pdf" download>

Two details trip people up. The download attribute only works for files on your own site (the same origin); for other URLs the browser just opens the link. And a jump link needs a matching id that is unique on the page and has no spaces, so use id="shipping-costs", not id="shipping costs".

How search engines use anchor tags

Search engines find pages by following links, and for Google that means anchor tags with an href. Google says it can only reliably crawl links written that way. Links built from other markup, like <a routerLink="...">, <span href="..."> or <a onclick="..."> without a real href, may not be followed. Google Search Central

Google also reads the anchor text to understand what the linked page is about. When the link is an image, the image's alt text plays that role. So your internal links do two jobs at once: they let crawlers reach your pages and they describe those pages.

For links you don't vouch for, add a rel value. Google asks for rel="sponsored" on paid links and ads, rel="ugc" on links in comments and forum posts, and rel="nofollow" for other cases where you don't want to be associated with the page. You can combine them, as in rel="ugc nofollow". Google Search Central See nofollow for more.

target="_blank" opens the link in a new tab or window. Older guides say you must always add rel="noopener" for security. Current browsers apply that protection automatically when you use target="_blank", so adding it is harmless but no longer required. MDN Use new tabs sparingly, and say so in the link text when it matters to the reader.

Common mistakes

  • Links that are really buttons. An <a href="#"> or href="javascript:void(0)" that only runs a script breaks opening in a new tab and bookmarking, and tells screen readers the wrong thing. If it doesn't go to a real URL, use a <button>.
  • "Click here" as the link text. Screen reader users often hear a list of links out of context. Make the clickable words say where they lead: "read the shipping policy", not "click here".
  • Navigation that only works with JavaScript. If a menu builds links without href values, crawlers may never reach the pages behind it.
  • Broken jump links. A typo in the id, a duplicate id, or a space in it sends readers nowhere.

They sound alike but do different things. The <a> element is a visible link in the page body that people click. The <link> element sits in the page's <head>, is never shown, and connects the page to other resources: a stylesheet, an icon, or a canonical tag that points search engines to the preferred URL.

Seonio

Put it to work on your own site

Keyword research, traffic, backlinks and clustering in one place. Start with a free $1 to test, no card required.