Equality [=] Attribute Selector
Exactly matches the specified attribute value.

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 not supported in Web pages that are displayed in the Microsoft Internet Explorer 5 document mode (also known as "Quirks" mode). To use attribute selectors, add a !DOCTYPE directive that specifies a standard-based document. For more information, see Defining Document Compatibility.

Attributes are case-sensitive.

Example

The following style rule selects any attribute whose value is exactly "Value".

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Strict//EN">
<html>
<head>
    <style>
        .test          { display:none; }
        [attr="Value"] { display:block; }
    </style>
</head>
<body>
    <div class="test" attr="Value">Test for [=] (Value) succeeded.</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.

Standards Information

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

See Also

Tags :


Community Content

mr918729871
Attribute selectors DO NOT WORK IN IE7
Please please fix MS! This ONLY works with a Strict !DOCTYPE.

AaZmaN
Strict !DOCTYPE is full of bugs
Note Attribute selectors are enabled only in standards-compliant mode (strict !DOCTYPE ).

Strict !DOCTYPE is full of css bugs, fix all the standards-compliant bugs first!!!!!!

Page view tracker