This page is In Progress

Notice: The WebPlatform project has been discontinued when the Stewards partnership agreement ended in September 2015. This site has been frozen, and the assets we have created will remain.

Attribute selector


Allows to select tags that has an attributes. While it can match the class and the id selector, its specificity value is lower.


[sel=att] {...}


  • sel: The name of a tag property
  • att: Must be either an Identifier or a String.
  • "=": An equality expression, one of
    • = Exactly equals,
    • ^= Begins with,
    • $= Ends with,
    • ~= Contains (with word boundary),
    • *= Contains (without word boundary)


The following style rule selects any element with an “attr” attribute whose value is exactly "Value".

<!DOCTYPE html>
    <style type="text/css">
      .test          { display:none; }
      [attr="Value"] { display:block; }
    <div class="test" attr="Value">Test for [=] (Value) succeeded.</div>

Related specifications

Selectors Level 3
W3C Recommendation

See also

Related articles

CSS Attributes