The hreflang attribute hints at the human language of the resource linked by href. Allowed values match the global lang attribute: valid BCP 47 language tags such as en, en-US, or fr-CA.
Use it on <a>, <area>, and <link> when href is present. With rel="alternate", it marks a translation of the current document.
Baseline · Widely available.
Not deprecated and not experimental. The attribute is supported; it is advisory only (no built-in visual change).
Advisory — not authoritative.
After fetching a resource, user agents must use the resource’s own language information, not hreflang alone, to decide its language.
Syntax
HTML Syntax
syntax.html
<a href="url" hreflang="language-tag">
The same hreflang="language-tag" pattern works on <link> and <area>. For alternates in <head>, combine with rel="alternate".
No visible UI change. Head declares x-default, en, and de alternates (open Try It Yourself to inspect).
How It Works
x-default. Points to a global or language-picker URL used when nothing else matches.
List real languages too. Include each concrete tag such as en and de.
SEO convention. Widely used by search engines with alternate annotations; keep tags consistent across pages.
Still need valid pages. Every href must resolve to a real alternate, not a soft 404.
Edge Cases & Pitfalls
Most mistakes mix up lang and hreflang, or publish incomplete alternate sets.
advisory
No built-in browser UI
MDN: no built-in functionality. Do not expect redirects or auto language switching from hreflang alone.
lang
Not a substitute for lang
lang labels the current content. hreflang labels the linked URL. You usually need both on multilingual sites.
tags
Use valid BCP 47 tags
Prefer en-US over invented codes. Invalid tags may be ignored by agents.
seo
Return links both ways
Each language version should reference all alternates in the set. One-way annotations are a common crawl issue.
href
Requires href
On <link>, use hreflang only when href is present. Without a destination, the hint has nothing to describe.
Compatibility
Browser Support
hreflang is an HTML attribute for hyperlinks in the browser. It is not a Node.js, Deno, or Bun API.
✓ Baseline · Widely available
hreflang
Widely available as an advisory attribute on a, area, and link. Visual behavior does not change; search engines and tools may use the hint.
97%Global support (approx.)
Google ChromeAll
Full support
Mozilla FirefoxAll
Full support
Apple SafariAll
Full support
Microsoft EdgeAll
Full support
OperaAll
Full support
Samsung InternetAll
Full support
Internet ExplorerAll
Supported
hreflangWidely supported
Bottom line: Safe to use as language metadata. Pair with correct lang on the page and consistent alternate sets for multilingual SEO.
Remember
Key Takeaways
Role: hint the language of the linked URL (advisory).
Format: BCP 47 tags like en, en-US, fr-CA.
Alternates: use with rel="alternate" for translations.
vs lang:lang = this page; hreflang = linked page.
One line:hreflang tells agents what language the link points to — it does not change the page look.
Frequently Asked Questions
It hints at the human language of the linked resource. Values follow BCP 47 (same idea as the lang attribute). It is advisory — browsers do not treat it as the final authority after fetching the resource.
It applies to hyperlink-creating elements with href: a, area, and link. The common SEO pattern is <link rel="alternate" hreflang="..." href="..."> in the document head.
lang describes the language of the current element or page. hreflang describes the language of the URL you link to with href.
x-default is a common search-engine convention for a fallback alternate URL when no other language or region matches. It is widely used with rel=alternate language annotations.
No. MDN notes there is no built-in visual behavior. It is metadata for agents such as browsers and search engines.
Use a valid BCP 47 language tag, such as en, en-US, fr, or fr-CA. Invalid tags may be ignored.