CSS2 » Other » lang

Version: Level 2

Compability: Currently not supported by any browser.

lang(language code)

The lang pseudo-class is used to apply style to the contents of an element which is written in a foreign language. You must declare the language code be enclosing the language code within a pair of parentheses.

The language code is set by the ISO 639 and RFC 1776 standards.
You can select the language for the element or document by:

  • setting the language in the HTTP header,
  • or by using the lang attribute that is available in HTML and XHTML,
  • or by using a meta element that is available in HTML and XHTML.
A pseudo-class is assigned to a selector via following syntax:
selector:pseudo-class(language code) { property: value; ...; }
A pseudo-class can also be used with the value assigned as a class to a selector:
selector.class:pseudo-class(language code) { property: value; ...; }


<title>lang test</title>
<style type="text/css">
p:lang(fr) {color: red;}</style>
<p lang="fr">
Bonjour le monde!
Bonjour le monde!

Simulated output.

Language(s): CSS2

See Also: