Hyphen [|=] Attribute Selector New for Windows Internet Explorer 7

Matches any attribute value that is exactly equal, or optionally, followed by a hyphen.


HTML [att|=val] { sRules }
Scripting N/A

Possible Values

att Must be either an Identifier or a String.
val Must be either an Identifier or a String.
sRules String that specifies one or more Cascading Style Sheets (CSS) attribute/value pairs.


This selector is available as of Internet Explorer 7.

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.


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

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

<div class="test" attr="en-us">Test for [|=] (Hyphen) succeeded.</div>

Standards Information

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

See Also

Class Selector, Equality [=] Attribute Selector, Existence [] Attribute Selector, ID Selector, Prefix [^=] Attribute Selector, Substring [*=] Attribute Selector, Suffix [$=] Attribute Selector, Type Selector, Universal (*) Selector, Whitespace [~=] Attribute Selector