YouTip LogoYouTip

Att Link Hreflang

## HTML <link> hreflang Attribute The `hreflang` attribute of the `` tag specifies the language of the text in the linked document. It is primarily used to help search engines serve the correct language or regional URL to searchers based on their location and language preferences. --- ## Definition and Usage * The `hreflang` attribute indicates the language of the destination resource. * This attribute can only be used if the `href` attribute is present. * **Note:** The `hreflang` attribute is purely advisory. Browsers do not use it to change the rendering of the page, but search engines (like Google) and custom scripts heavily rely on it for internationalization (i18n) and SEO. --- ## Browser Support | Attribute | Chrome | Edge/IE | Firefox | Safari | Opera | | :--- | :--- | :--- | :--- | :--- | :--- | | **hreflang** | Yes | Yes | Yes | Yes | Yes | *Note: While mainstream browsers do not directly alter the page display based on this attribute, it is fully supported and recognized by search engines and web crawlers for localization.* --- ## Syntax ```html ``` --- ## Attribute Values | Value | Description | | :--- | :--- | | *language_code* | Specifies a two-letter ISO 639-1 language code (e.g., "en" for English, "es" for Spanish, "zh" for Chinese). It can also include an optional regional subtag (e.g., "en-us" or "en-gb"). | --- ## Code Examples ### Example 1: Basic Usage In this example, the `hreflang` attribute indicates that the linked document is written in English: ```html ``` ### Example 2: Multi-language SEO (Internationalization) If you have a website translated into multiple languages, you can use the `hreflang` attribute inside the `` section to tell search engines about the localized versions of your page: ```html ``` --- ## HTML 4.01 vs. HTML5 There are no functional differences for this attribute between HTML 4.01 and HTML5. However, in HTML5, the use of `hreflang` combined with `rel="alternate"` has become the industry standard for search engine optimization (SEO) on multilingual websites.
← Att Link MediaAtt Link Href β†’