How to use CSS language Selector :lang

Description

The :lang selector matches elements based on the lang attribute.

The :lang Selector has the following syntax:

Selector: :lang(target language)

Example


<!DOCTYPE HTML> 
<html> 
    <head> 
        <style type="text/css"> 
        :lang(en) { <!-- w  ww  .j a va2s. c  o  m-->
            border: thin black solid; 
            padding: 4px; 
        } 
        </style> 
    </head> 
    <body> 
        <a lang="en-us" href="http://java2s.com"> 
        Visit the java2s.com </a> 
        <span lang="en-uk">HTML</span>
        <a lang="en" href="http://w3c.org">
        Visit the W3C website</a> 
    </body> 
</html>

Click to view the demo

The code above generates the following result.

:lang




















Home »
  HTML CSS »
    HTML CSS Reference »




HTML Tag Reference
CSS Reference
CSS Selector Reference
Encoding Reference