CSS3/Selectors/attribute selector/attribute
[attributename]
This selector represents an element with a "attributename" attribute, whatever the value of the attribute.
Syntax
elementname[attributename]{ properties }
Example
The following attribute selector represents an p element that carries the title attribute, whatever its value:
[style.css]
p[title]{ color: red; font-size: 1.2em; }
[index.html]
<body> <p title="sample text">This is a paragraph.(with title attribute)</p> <p>This is a paragraph.</p> </body>
The CSS Selectors Level 3 specification defines the attribute selector in 6.3.1. Attribute presence and value selectors.