CSS | :lang Selector

The :lang Selector is used to target the element which is based on language attributes for a specific value. This selector work with the help of language-code.

Syntax:

:lang(lang-code) {
  //property
}

Language Codes:



  • en: for English.
  • hi: for Hindi.
  • fr: for French.
  • de: for German
  • it: for Italian
  • ca: for Canadian

Example-1:

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
  
<head>
    <style>
        h3:lang(en) {
            background: limegreen;
        }
    </style>
</head>
  
<body>
  
    <h3 lang="en">"en" is lang-code for english.</h3>
  
</body>
  
</html>

chevron_right


Output:

Example-2: Language code apply on root element.

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
  
<head>
    <style>
        h3:lang(en) {
            background: limegreen;
        }
    </style>
</head>
  
<body lang="en">
  
    <h3>"en" is lang-code for English.</h3>
    <h3>"fr" is lang-code for French.<h3>
<h3>"de" is lang-code for German.<h3>
</body>
</html>

chevron_right


Output:

Supported Browsers:

  • Google Chrome 4.0
  • Edge 8.0
  • Firefox 2.0
  • Safari 3.1
  • Opera 9.6


My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.