HTML lang Attribute: This attribute defines the language of the content of the element. Some of the examples for languages are en for English, es for Spanish, etc. The lang attribute will guide the search engine and browsers to understand the basic language for the website. Based on the ISO standard each language will have a unique code to declare in the lang attribute.
HTML lang Attribute
This attribute can be applied to all the HTML elements.
Attribute Value: This attribute contains single value language_code which is used to specify the language of the content.
Syntax: <element lang = “language_code”>
Browser Support
This attribute is supported by the following browsers:
- Chrome
- Firefox
- Internet Explorer
- Safari
- Opera
Example: for lang Attribute
<!DOCTYPE html> <html> <head> <title>lang attribute</title> <style> body { text-align:center; } h1 { color:green; } </style> </head> <body> <h1>Freshersnow</h1> <h2>lang attribute</h2> <p lang = "en">A tutorial and job portal for Freshers</p> </body> </html>
Output: