Little Web Hut
(Cascading Style Sheets) CSS 2.1 Reference

CSS [AttributeName=AttributeValue] Selector

 

What is a CSS [AttributeName=AttributeValue] Selector?

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