- HTML Tutorial
- HTML - Home
- HTML - Introduction
- HTML - Editors
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Headings
- HTML - Paragraphs
- HTML - Fonts
- HTML - Blocks
- HTML - Style Sheet
- HTML - Formatting
- HTML - Quotations
- HTML - Comments
- HTML - Colors
- HTML - Images
- HTML - Image Map
- HTML - Iframes
- HTML - Phrase Elements
- HTML - Meta Tags
- HTML - Classes
- HTML - IDs
- HTML - Backgrounds
- HTML Tables
- HTML - Tables
- HTML - Headers & Caption
- HTML - Table Styling
- HTML - Table Colgroup
- HTML - Nested Tables
- HTML Lists
- HTML - Lists
- HTML - Unordered Lists
- HTML - Ordered Lists
- HTML - Definition Lists
- HTML Links
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML Color Names & Values
- HTML - Color Names
- HTML - RGB
- HTML - HEX
- HTML - HSL
- HTML Forms
- HTML - Forms
- HTML - Form Attributes
- HTML - Form Control
- HTML - Input Attributes
- HTML Media
- HTML - Video Element
- HTML - Audio Element
- HTML - Embed Multimedia
- HTML Header
- HTML - Head Element
- HTML - Adding Favicon
- HTML - Javascript
- HTML Layouts
- HTML - Layouts
- HTML - Layout Elements
- HTML - Layout using CSS
- HTML - Responsiveness
- HTML - Symbols
- HTML - Emojis
- HTML - Style Guide
- HTML Graphics
- HTML - SVG
- HTML - Canvas
- HTML APIs
- HTML - Geolocation API
- HTML - Drag & Drop API
- HTML - Web Workers API
- HTML - WebSocket
- HTML - Web Storage
- HTML - Server Sent Events
- HTML Miscellaneous
- HTML - MathML
- HTML - Microdata
- HTML - IndexedDB
- HTML - Web Messaging
- HTML - Web CORS
- HTML - Web RTC
- HTML Demo
- HTML - Audio Player
- HTML - Video Player
- HTML - Web slide Desk
- HTML Tools
- HTML - Velocity Draw
- HTML - QR Code
- HTML - Modernizer
- HTML - Validation
- HTML - Color Picker
- HTML References
- HTML - Cheat Sheet
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Entities
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
- HTML Resources
- HTML - Quick Guide
- HTML - Useful Resources
- HTML - Color Code Builder
- HTML - Online Editor
HTML - lang Attribute
HTML lang attribute is global attribute that is used to define the language of an element's content.
In HTML documents, the <html> tag accepts the lang attribute, which is by default unknown. If you pass the value of the lang attribute, then the user will know that the content of this element is in this language, like English, Spanish, French, and so on.
The default value of lang is unknown; therefore, it is recommended to always specify this attribute with the appropriate value.
Syntax
<element lang = "value" >
This attribute holds any valid language code.
Applies On
Since lang is a global attribute in HTML, all the tags in HTML support lang attribute.
Examples of HTML lang attribute
Below examples will illustrate the HTML lang attribute, where and how we should use this attribute!
Define french Language
In the following example, we are using the lang attribute along with elements to define the language of the content.
<!DOCTYPE html> <html> <body lang="fr"> <p> This paragraph is English, but the language is not specifically defined. </p> <p> This paragraph is defined as British English. </p> <p> Ce paragraphe est défini en français. </p> </body> </html>
Define Multiple Languages on single Document
Considering the another scenario, where we are going to use the lang attribute with arabic and hindi. Arabic languages text direction is changed as it should start from right using dir attribute.
<!DOCTYPE html> <html> <body> <p lang="ar" dir=rtl > هذا الفقرة محدد باللغة العربية. </p> <p lang="hi"> यह पैराग्राफ हिंदी में परिभाषित है। </p> </body> </html>
Supported Browsers
Attribute | |||||
---|---|---|---|---|---|
lang | Yes | Yes | Yes | Yes | Yes |
To Continue Learning Please Login
Login with Google