Using the :lang Selector

Description

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

Example

The following code shows the lang selector in use.


<!DOCTYPE HTML>
<html>
<head>
<style type="text/css">
:lang(en) {<!--from  ww w .j  a  v a  2 s .  c  o m-->
  border: thin black solid;
  padding: 4px;
}
</style>
</head>
<body>
  <a lang="en-us" id="anchor" class="class1 class2"
    href="http://java2s.com"> Visit the website </a>
  <p>
    I like <span lang="en-uk" class="class2">HTML</span> and CSS.
  </p>
  <a lang="en" id="w3canchor" href="http://w3c.org">Visit the W3C
    website</a>
</body>
</html>

Click to view the demo

This selector matches elements that have a lang attribute that denotes they are written in English.





















Home »
  HTML CSS »
    CSS »




CSS Introduction
CSS Background
CSS Border
CSS Box Layout
CSS Text
CSS Font
CSS Form
CSS List
CSS Selectors
CSS Others
CSS Table