head lang attribute
The lang attribute on the head element:
- → allows you to specify the language of the element in cause; affected parts: the content of the element and the value of the attributes of that element, if type text. The language attribute is useful for user agents in order to proper interpret and render your web page
- is a global attribute → can be applied on all html elements;
- when applied on <head>, its value is inherited by all elements that goes inside this section: e.g. title, meta..
Recommendation: specify the language of the document on the html root element; it is considered good practice.
Examples
<head | attribute | = | "value(s)" | > | ... | <⁄head> | example |
---|---|---|---|---|---|---|---|
16. | lang | = | language code | <lang="en"> ... <⁄ > <lang="fr"> ... <⁄ > |
Video demonstration head lang attribute
HTML5 head lang attribute Tutorial
min | video details |
---|---|
00:10 | page's content is in French |
00:20 | we can add the lang attribute, with an "fr" value to the html root element |
00:28 | but title's page is in English |
00:41 | we can add the lang attribute with an "en" value straight to title or to head element |