YouTip LogoYouTip

Att A Hreflang

## HTML `` `hreflang` Attribute The `hreflang` attribute of the `` (anchor) tag specifies the language of the linked document. It helps search engines and browsers understand the language of the target page before a user clicks the link. --- ## Browser Support The `hreflang` attribute is fully supported by all major modern web browsers: * Google Chrome * Mozilla Firefox * Microsoft Edge / Internet Explorer * Safari * Opera --- ## Definition and Usage * The `hreflang` attribute indicates the language of the destination URL specified in the `href` attribute. * **Prerequisite:** This attribute is only functional when the `href` attribute is present on the `` tag. * **Difference from `lang`:** Unlike the global `lang` attribute (which defines the language of the element's *current* content), the `hreflang` attribute specifies the language of the *linked* document. --- ## HTML 4.01 vs. HTML5 There are no differences in the behavior or support of the `hreflang` attribute between HTML 4.01 and HTML5. --- ## Syntax ```html Link Text ``` ### Attribute Values | Value | Description | | :--- | :--- | | *`language_code`* | A two-letter ISO 639-1 language code (e.g., `en` for English, `es` for Spanish, `fr` for French) that specifies the language of the linked document. It can also include an optional country code suffix (e.g., `en-us` or `en-gb`). | --- ## Code Examples ### Example 1: Linking to an English Document In this example, the link points to an English website. The `hreflang` attribute informs search engines and browsers that the destination page is in English. ```html Visit our English Site ``` ### Example 2: Linking to Multiple Language Versions This is a common pattern for multi-language websites, allowing users and search crawlers to navigate between localized versions of a page. ```html

This article is also available in other languages:

``` --- ## Important Considerations 1. **SEO Best Practices:** While the `hreflang` attribute on `` tags provides semantic hints to search engines, for comprehensive international SEO, it is highly recommended to also use `` tags inside the `` section of your HTML document, or configure them via HTTP headers and XML Sitemaps. 2. **User Experience:** Browsers do not automatically translate pages based on the `hreflang` attribute. It is primarily used by search engines to serve the correct language version of a page in localized search results.
← Att A RevAtt A Href β†’