Skip to: content, navigation

:lang(C) (CSS selector)

Spec
Version
CSS2
Browser support (more…)
IE7 FF1+ SA3+ OP9.2+
None Full Buggy 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
5.5 6.0 7.0 1.0 1.5 2.0 1.3 2.0 3.0 9.2 9.5
None None None Full Full Full None None Buggy Full Full

In Safari 3, 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
Status:
This note has not yet been confirmed for accuracy and relevance.

"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.

Add a note

To post a note on this topic, please log in with your SitePoint username and password. If you don't have an account yet, you can create a new account for free.

Related Products

Search