CSS/Selectors/attribute selector/attributel=value

From Web Education Community Group
< CSS‎ | Selectors
Jump to: navigation, search


This selector represents an element with the "attributename" attribute, its value either being exactly "val" or beginning with "val" immediately followed by "-".


elementname[attributename|="val"]{ properties }

Point, Note

  • This is primarily intended to allow language subcode matches.


The following selector represents an a element for which the value of the hreflang attribute begins with "en", including "en", "en-US", and "en-scouse":


   font-style: italic;


  <p><a href="http://www.w3.org/" hreflang="en-US">W3C</a> is an international community</p>

Css3 selectors att 004.png

CSS defines the attribute selector in 6.3.1. Attribute presence and value selectors.