Link hreflang Attribute

Definition and Usage

hreflang The attribute sets or returns the language code of the linked document.

The hreflang attribute will not be displayed as any special content in any mainstream browser. However, it can be used by search engines or scripts.

Tip:To view all available language codes, please visit ourLanguage Code Reference Manual.

See also:

HTML Reference Manual:HTML <link> hreflang-Attribut

HTML Reference Manual:HTML <link>-Tag

Example

Example 1

Return the language code of the linked document:

var x = document.getElementById("myLink").hreflang;

Try it yourself

Example 2

Change the language code of the linked document:

document.getElementById("myLink").hreflang = "en-us";

Try it yourself

Syntax

Return the hreflang attribute:

linkObject.hreflang

Set the hreflang attribute:

linkObject.hreflang = languagecode

Attributswert

Wert Beschreibung
languagecode Gibt den Sprachcode des verlinkten Dokuments an.

Technische Details

Rückgabewert: Zeichenfolgenwert, der die Sprachcodes des verlinkten Dokuments darstellt.

Browserunterstützung

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Unterstützung Unterstützung Unterstützung Unterstützung Unterstützung