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
}
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.
Compatibility
| IE | 5.5 | None |
|---|---|---|
| 6.0 | None | |
| 7.0 | None | |
| Firefox | 1.0 | Full |
| 1.5 | Full | |
| 2.0 | Full | |
| Safari | 1.3 | None |
| 2.0 | None | |
| 3.0 | Buggy | |
| Opera | 9.2 | Full |
| 9.5 | Full |
In Safari 3, this selector only matches elements on which the attribute is set explicitly—not those for which it’s inherited.
Related Reading
User-contributed notes
There are no comments yet.
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.

