Little Web Hut
(Cascading Style Sheets) CSS 2.1 Reference

CSS [AttributeName] Selector

 

What is a CSS [AttributeName] Selector?

  • This selector specifies an element that has the specified attribute set. It does not matter what the attribute value is, but rather it only matters that the attribute is set. In the following example, the color property will be set to red for any <p> element whose title attribute is set. The style is NOT applied to the second <p> element.
CSS Example:
  p[title] {color: red;}
  <p title="sample title">The red style has been applied to this element.</p>
  <p>The red style has not been applied to this element.</p>
Test It HTML StyleTest It XHTML StyleTest It HTML5 Style