1 out of 2 rated this helpful - Rate this topic

:lang pseudo-class

[This documentation is preliminary and is subject to change.]

In a document, selects the elements that are in a given language.

CSS 2.1, Section 5.11.4Internet Explorer 8

Syntax

selector :lang(C) {...}

Parameters

selector

A CSS simple selector

C

Language code

Standards information

Remarks

The set rules are applied when the value of C matches (or is a hyphen-separated substring of) the element's language value. The value of C should be a language code that is indicated by RFC3066: Tags for the Identification of Languages.

If C is empty or invalid, the selector will have no effect.

This pseudo-class requires that Windows Internet Explorer be in IE8 Standards mode rendering. For more information, see Defining Document Compatibility.

Examples

The following code example uses the :lang pseudo-class to apply a color to any p elements that are explicitly given a language value of "en" (or a hyphen-separated subset thereof). The first paragraph gets "en-us" (a subset of "en") and thus turns green.

Click to view sample.


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" 
    "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=8" />
<title>:lang pseudo-class</title>
<style type="text/css">
p:lang(en) {
	color: green;
}
</style>
</head>
<body>
<div class="body">
	
	<h1>:lang(C) Sample</h1>
	
	<!-- This paragraph gets "en-us" (a subset of "en") and thus turns green. -->
	<p lang="en-us">This paragraph's language is set to "en-us", so it's green.</p>
	<!-- This paragraph has no language value and thus does not turn green. -->
	<p>This paragraph has no language attribute, so it doesn't turn green.</p>
	<!-- This paragraph is actually a div; therefore, even though its language value 
	    is "en-us", it does not turn green. -->
	<div lang="en-us">This div's language is set to "en-us", but this page's :lang 
	    pseudo-class only applies to paragraphs, so it doesn't turn green.</div>
		
</div>
</body>
</html>

 

 

Build date: 3/14/2012

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
:lang(C) Pseudo-Class
:lang(C) Pseudo-Class (A, ABBR, ACRONYM, ...)