Open In App

What is the difference between <html lang=”en’> and <html lang=”en-US’> ?

The lang attribute specifies which language is used to write the content of a web page. It is used to set the language for the whole text of the web page.

The <html lang="en"> specifies the language of the document as English, while <html lang="en-US"> narrows it down to English as used in the United States.



<html lang=”en”>

The <html lang=”en’> only specifies the language code of the page meaning en or English is used for all the text on the page.



Example: In this example, we will see the use of lang ‘en’ in an HTML document.




<!DOCTYPE html>
<html lang="en">
 
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,
    initial-scale=1.0">
    <title>lang Attribute</title>
    <style>
        body {
            text-align: center;
        }
 
        h1 {
            color: green;
        }
    </style>
</head>
 
<body>
    <h1>GeeksforGeeks</h1>
    <p>
        jQuery is an open source JavaScript library that
        simplifies the interactions between an HTML/CSS document,
        or more precisely the Document Object Model (DOM), and JavaScript.
        Elaborating the terms, jQuery simplifies HTML document
        traversing and manipulation, browser event handling,
        DOM animations, Ajax interactions, and cross-browser
        JavaScript development.
    </p>
</body>
 
</html>

Output:

<html lang=”en-US”>

The <html lang=”en-US’> specifies the language code of the page followed by the country code that means US style of English language is used for all the text on the page.

<html lang=”en-GB’> which means the United Kingdom style of English
<html lang=”en-IN’> which means the Indian style of English

Example 2: In this example, we will see the use of lang ‘US’ in an HTML document.




<!DOCTYPE html>
<html lang="en-US">
 
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width,
    initial-scale=1.0">
    <title>lang Attribute</title>
    <style>
        body {
            text-align: center;
        }
 
        h1 {
            color: green;
        }
    </style>
</head>
 
<body>
    <h1>GeeksforGeeks</h1>
    <p>
        jQuery is an open source JavaScript library that
        simplifies the interactions between an HTML/CSS document,
        or more precisely the Document Object Model (DOM), and JavaScript.
        Elaborating the terms, jQuery simplifies HTML document
        traversing and manipulation, browser event handling,
        DOM animations, Ajax interactions, and cross-browser
        JavaScript development.
    </p>
</body>
 
</html>

Output:


Article Tags :