- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to specify the language of the element's content in HTML?
The language of an element's content can be identified using the HTML lang property. Language code, which is used to specify the language of the displayed information, is the only value for this element.
Syntax
<p lang = “required language”>
Following are the examples…
Example
In the following example we are using lang property to specify the language of the element content.
<!DOCTYPE html> <html> <body> <h1>English</h1> <p lang="en"> The Best E-Way Learning. </p> <h2>french</h2> <p lang="fr"> Le meilleur apprentissage E-Way. </p> </body> </html>
Output
On executing the above script, it will display two texts in different languages as we mentioned in the script.
Example
Here, we have added content in French and Spanish as well.
<!DOCTYPE html> <html> <body> <h2>English</h2> <p lang = "en">This is demo text</p> <h2>French</h2> <p lang = "fr">Ceci est un texte de démonstration</p> <h2>Spanish</h2> <p lang = "es">Este es un texto de demostración</p> </body> </html>
Output
The output obtained after executing the script above is −
- Related Articles
- How to specify that the styles only apply to this element's parent element and that element's child elements in HTML?
- How to specify whether the content of an element should be translated or not in HTML?
- How to specify the HTML content of the page to show in the <iframe> in HTML?
- How to adopt a flex div's width to content in HTML?
- How to add multi-language content in HTML?
- How to get the body's content of an iframe in JavaScript?
- How to specify that the element is read-only in HTML?
- Which event occurs in JavaScript when an element's content is cut?
- Which event occurs in JavaScript when an element's content is pasted?
- How to specify whether the or the element should have autocomplete enabled in HTML?
- What to do when an element's content might be larger than the amount of space allocated to it?
- How to specify the type of box used for an HTML element using CSS?
- How to set HTML content of an element using jQuery?
- How to get HTML content of an element using jQuery?
- How to specify the usage of an element using the tabbing order (tab keyboard button) in HTML?

Advertisements