Skip to: content, navigation

by Tommy Olsson and Paul O’Brien

:lang(C) (CSS selector)

Browser support full matrix
IE7 FF1+ Saf3+ Op9.2+
None Full Buggy Full
Spec
Version
CSS2

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
}

Try it yourself!View all demos

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

IE5.5None
6.0None
7.0None
Firefox1.0Full
1.5Full
2.0Full
Safari1.3None
2.0None
3.0Buggy
Opera9.2Full
9.5Full

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.

Related Products

The Principles of Beautiful Web Design

Best Seller!

You don’t need to go to Art School to design great looking web sites!

Book Cover: The Principles of Beautiful Web Design

Download the FREE sample chapters