:lang(C) (CSS selector)

Spec
Version
CSS2
Browser support (more…)
IE8+ FF1+ SA3.1+ OP9.2+ CH2+
Full Full Full Full Full

Syntax

:lang(language code) {
declaration block
}

Description

If you specify a language using this pseudo-class, it’ll match any element for which the same language is specified. The argument is matched in a similar way to the |= operator in attribute selectors—it can be an exact match, or a match to a hyphen-separated substring.

The document language specifies how the language of an element is set. In HTML, the language doesn’t have to be set explicitly on the element—it can be inherited. As such, this pseudo-class differs from the [lang|=xx] attribute selector, which only matches elements that have a lang attribute.

Example

The following rule set will be applied to elements whose language specification is "fr" (French), "fr-be" (French/Belgium), "fr-ca" (French/Canada), and so on:

:lang(fr) {
  ⋮ declarations
}

Compatibility

Internet Explorer Firefox Safari Opera Chrome
5.5 6.0 7.0 8.0 1.0 1.5 2.0 3.0 3.5 1.3 2.0 3.1 4.0 9.2 9.5 10.0 2.0
None None None Full Full Full Full Full Full None None Full Full Full Full Full Full

In Safari 3.0, this selector only matches elements on which the attribute is set explicitly—not those for which it’s inherited.

User-contributed notes

ID:
#1
Contributed:
by Buran
Date:
Thu, 24 Jul 2008 06:44:54 GMT

"In Safari 3, this selector only matches elements on which the attribute is set explicitly—not those for which it’s inherited."

I tested in Safari 3.1.2 Win. Inherited lang-attribute _supported_. Need to be tested on 3.1.* Win & Mac.

Related Products