CSS/Selectors/attribute selector/attribute

From W3C Wiki
< CSS‎ | Selectors
Jump to: navigation, search


This selector represents an element with a "attributename" attribute, whatever the value of the attribute.


elementname[attributename]{ properties }


The following attribute selector represents an p element that carries the title attribute, whatever its value:


   color: red;
   font-size: 1.2em;


  <p title="sample text">This is a paragraph.(with title attribute)</p>
  <p>This is a paragraph.</p>

Css3 selectors att 001.png

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