Skip to content
Related Articles

Related Articles

Which attribute is used to declare the language of the web page in HTML ?

View Discussion
Improve Article
Save Article
Like Article
  • Last Updated : 30 Jan, 2022

The HTML lang attribute is used to declare the language of the element content it is used on. Some examples of languages are en for English, es for Spanish, etc. This attribute contains a single value, which is the language_code that is used to specify the language of the content that is displayed.

Syntax:

<element lang="language_code">

The below examples illustrate the lang attribute declaration:

Example 1: In this example we will use ‘en’ for the English language.

HTML




<!DOCTYPE html>
<html>
  
<head>
    <style>
        body {
            text-align: center;
        }
  
        h1 {
            color: green;
        }
    </style>
</head>
  
<body>
    <h1>GeeksforGeeks</h1>
    <h2>
        Which attribute is used to declare
        the language of the web page in HTML?
    </h2>
  
    <p lang="en">
        A computer science portal for geeks
    </p>
</body>
  
</html>

Output:

Example 2: In this example we will use ‘fr’ for the French language.

HTML




<!DOCTYPE html>
<html>
  
<head>
    <style>
        body {
            text-align: center;
        }
  
        h1 {
            color: green;
        }
    </style>
</head>
  
<body>
    <h1>GeeksforGeeks</h1>
    <h2>
        Which attribute is used to declare
        the language of the web page in HTML?
    </h2>
  
    <p lang="fr">
        Un portail informatique pour les geeks
    </p>
</body>
  
</html>

Output:


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!