link hreflang attribute
The hreflang attribute on the link element:
- allows you to add the language of the linked resource; this information is purely advisory
- hreflang is a specific attribute → can be applied ONLY on the next HTML5 elements: a, area, link
Warning:
- hreflang attribute can be used only if href attribute is present on link element;
while href allows us to link an external resource to the page, the hreflang allows us to specify its language!
Examples
<link | attribute | = | "value(s)" | > | Examples | ||
---|---|---|---|---|---|---|---|
2. | hreflang | = | language code | <rel="alternate" href="URL" hreflang="language_code"> |
Video demonstration link hreflang attribute
HTML5 link hreflang attribute Tutorial
min | video details |
---|---|
00:09 | this video tutorial presents the hreflang attribute on link element |
00:19 | <link rel="author" href="about_author.php"> the linked resource "about_author.php" holds information about the the author of the current document the language of the resource "about_author.php" is English and we can specify this as a purely advisory information for user agents through hreflang attribute |
00:29 | adding the hreflang attribute to link element |
00:37 | adding the language code for English language which is: en |
00:42 | that's it; you're done! this is how you can specify the language of the linked resource on a link element |