# \[hreflang\]

> The `hreflang` HTML attribute specifies the language of the linked document.

## How do I use hreflang for multilingual pages?

The attribute of `<a>` and `<link>` that tells which language the linked page is in. With `<link rel="alternate">`, it lists translated versions of a page, so search engines show users the version in their language.

- Topic: Links
- Type: attribute
- Browser support: Chrome 1+, Chrome Android 18+, Edge 12+, Firefox 1+, Firefox Android 4+, Safari 4+, Safari iOS 3.2+

## Example

Wrong:

```html
<link rel="alternate" hreflang="en-uk" href="https://example.com/uk/">
<link rel="alternate" hreflang="es" href="https://example.com/es/">
```

Right:

```html
<link rel="alternate" hreflang="en-GB" href="https://example.com/uk/">
<link rel="alternate" hreflang="es" href="https://example.com/es/">
<link rel="alternate" hreflang="x-default" href="https://example.com/">
```

Region codes are country codes, so the UK is 'en-GB', and 'x-default' covers all other visitors.

## Common mistakes

- Adding `hreflang` only on the main page and not on the translated pages.

## Key points

- Every language version links to all other versions and to itself.
- Values are valid language codes like 'en' or 'pt-BR', and an 'x-default' version exists.

## Interview questions

### Does hreflang on a normal link change anything for users?

No, on `<a>` it is only a hint about the target's language. Search engines read `hreflang` on `<link rel='alternate'>`.

### Can I set hreflang in a sitemap instead of HTML?

Yes, search engines also read `hreflang` from XML sitemaps and HTTP headers, so you can pick one method.

## Related cards

- [\[lang\]](https://wonderium.dev/html/lang.md)
- [i18n](https://wonderium.dev/web/i18n.md)
- [Locale](https://wonderium.dev/web/locale.md)
- [SEO](https://wonderium.dev/web/seo.md)

---

- Level: [HTML](https://wonderium.dev/html.md)
- HTML version: https://wonderium.dev/html/hreflang
- Last updated: 2026-11-25
