title lang attribute
The lang attribute on the title 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 <title>, it specify the language of the document's title;
Recommendation: specify the language of the document on the html root element; it is considered good practice.
Examples
<title | attribute | = | "value(s)" | > | ... | <⁄title> | example |
---|---|---|---|---|---|---|---|
16. | lang | = | language code | <lang="en"> ... <⁄ > <lang="fr"> ... <⁄ > |
Video demonstration title lang attribute
HTML5 title lang attribute Tutorial
min | video details |
---|---|
00:06 | launching lang.php file in browser |
00:09 | page's content is in French |
00:20 | opening lang.php file in Notepad++ |
00:23 | the html root element has the value of the lang attribute:"fr", which corresponds with the page content's language |
00:30 | but the page title is in English |
00:23 | because the page's content is in French we can add the lang attribute on the html root element, with the value "fr" |
00:27 | page's title is in English |
00:42 | because the page's title is in English we can add the lang attribute on title element, with the value "en" |
note: althought page's language is set to French, by adding the lang attribute on the html root element, this value won't be applied on title element because on an element level, title, we specified a new language, this last one applies |