Click to Rate and Give Feedback
MSDN
MSDN Library
Web Development
HTML and CSS
CSS Reference
Selectors
Attribute Selectors
 Existence [] Attribute Selector

  Switch on low bandwidth view
Existence [] Attribute Selector
Matches the attribute, whatever its value.

Syntax

HTML[att] { sRules }
ScriptingN/A

Possible Values

attMust 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.

Example

The following style rule selects elements that use the "special" attribute.

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Strict//EN">
<html>
<head>
    <style>
        .test     { display:none; }
        [special] { display:block; }
    </style>
</head>
<body>
    <div class="test" special>Test for [] (Existence) 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 Cascading Style Sheets (CSS), Level 3 (CSS3).

See Also

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker