Whitespace [~=] Attribute Selector
Exactly matches the specified attribute value in a space-delimited list of values.

Syntax

HTML[att~=val] { sRules }
ScriptingN/A

Possible Values

attMust be either an Identifier or a String.
valMust be either an Identifier or a String.
sRulesString that specifies one or more Cascading Style Sheets (CSS) attribute/value pairs.

Remarks

Note   Requires Windows Internet Explorer 7 or later.
Note   Attribute selectors are enabled only in standards-compliant mode (strict !DOCTYPE).

Attributes are case-sensitive.

If the target val contains whitespace, the rule will not match anything.

Example

The following style rule selects any attribute whose value contains the token "Two".

<style>
    .test         { display:none; }
    [attr~="Two"] { display:block; }
</style>

<div class="test" attr="One Two Three">Test for [~=] (Token) succeeded.</div>
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.

Standards Information

This selector is defined in CSS, Level 2 Revision 1 (CSS2.1).

See Also

Tags :


Page view tracker