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

  Switch on low bandwidth view
Hyphen [|=] Attribute Selector
Matches any attribute value that is exactly equal, or optionally, followed by a hyphen.

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

The hyphen is used primarily as a delimiter for language codes.

Attributes are case-sensitive.

Example

The following style rule selects any attribute whose value begins with "en" and is immediately followed by a hyphen.

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

<div class="test" attr="en-us">Test for [|=] (Hyphen) 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 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