Развернуть
:lang(C) Pseudo-Class
New for Windows Internet Explorer 8

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

Syntax

HTML:lang(C) { sRules }
ScriptingN/A

Possible Values

sRulesString that specifies one or more Cascading Style Sheets (CSS) attribute-value pairs.

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 RFC-3066 World Wide Web link.

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

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

Example

The following code example, which is reproduced from the Windows Internet Explorer Testing Center on MSDN, uses the :lang pseudo-class to apply a color to any p elements that are explicitly given a language value (or a hyphen-separated subset thereof) of "en." The first paragraph gets "en-us" (a subset of "en") and thus turns green.


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>:lang pseudo-class</title>
        <style type="text/css">
            p:lang(en)
            {
                color: green
            }
        </style>
    </head>
    <body>
        <p lang="en-us">This text should be green.</p>
        <p>This text should NOT be green.</p>
        <div lang="en-us">This text should NOT be green.</div>
    </body>
</html>

This feature requires Windows Internet Explorer 7 or later. Click the following icon to install the latest version. Then reload this page to view the sample.

Applies To

A, ABBR, ACRONYM, ADDRESS, B, BIG, BLOCKQUOTE, BODY, CAPTION, CENTER, CITE, CODE, COL, COLGROUP, DD, DFN, DIR, DIV, DL, DT, EM, FORM, hn, HTML, I, IMG, INPUT, INPUT type=button, INPUT type=checkbox, INPUT type=file, INPUT type=image, INPUT type=password, INPUT type=radio, INPUT type=reset, INPUT type=submit, INPUT type=text, KBD, LABEL, LEGEND, LI, LISTING, MARQUEE, MENU, OL, P, PRE, S, SAMP, SELECT, SMALL, SPAN, STRIKE, STRONG, SUB, SUP, TABLE, TBODY, TD, TEXTAREA, TFOOT, TH, THEAD, TR, TT, U, UL, VAR
Содержимое сообществаДобавить
Page view tracker