HTML lang Attribute

Last Updated : 20 May, 2026

The HTML lang attribute specifies the language of the content in an element, helping browsers and assistive technologies interpret it correctly.

  • Typically used in the <html> tag to define the page language.
  • Uses language codes like en, fr, hi, etc.
  • Improves accessibility and search engine understanding.
  • Helps screen readers pronounce content accurately.
html
<!--Driver Code Starts-->
<!DOCTYPE html>
<html>

<head>
    <title>lang attribute</title>
    <style>
        body {
            text-align:center;
        }
        h1 {
            color:green;
        }
    </style>
</head>

<body>
    <h1>GeeksforGeeks</h1>
    <h2>lang attribute</h2>

<!--Driver Code Ends-->

    <p lang="en">
        A computer science portal for geeks
    </p>

<!--Driver Code Starts-->
</body>

</html>
<!--Driver Code Ends-->

Syntax

<html lang="en">

The lang attribute specifies the language of the content, helping browsers and assistive technologies interpret and present it correctly.

Comment