Open In App

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

Improve
Improve
Like Article
Like
Save
Share
Report

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:



Last Updated : 30 Jan, 2022
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads