img lang attribute
The lang attribute on the img element:
- → allows you to specify the language of the alternative (alt) 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 the root element <html>, its value is inherited by all other html elements
Recommendation: specifying the language of the document on the html root element it is considered good practice.
Examples
<img | attribute | = | "value(s)" | > | Examples | ||
---|---|---|---|---|---|---|---|
16. | lang | = | language code | <src=".." alt="alt text " lang="en"> |
Video demonstration img lang attribute
HTML5 img lang attribute Tutorial
min | video details |
---|---|
00:06 | video tutorial: lang attribute on img |
00:11 | lang attribute on img allws you to specify the language of the alternative text added as value of the alt attribute |
00:15 | 1st image: the text "coucher de soleil" is in French → the lang="fr" |
00:26 | 2nd image: the text "sky" is in English → the lang="en" |
00:34 | 3rd image: the text "clouds" is in English → the lang="en" |