Description

Matches attributes of html elements.
E[attr] matches any element E with an attribute 'attr'

Common HTML4 attributes include: alt, id, class, title, style, height, width, align, valign, accesskey, tabindex.
In HTML5 the list of attributes has grown to include: contenteditable, contextmenu, draggable, hidden, item, itemprop, spellcheck, as well as custom defined attributes prefixed with data-.

See also:

  • Attribute selector contains [*]
  • Attribute selector ends with [$]
  • Attribute selector equal [=]
  • Attribute selector hyphen values [|]
  • Attribute selector in list [~]
  • Attribute selector starts with [^]
  • attr()
Live Example
Play with the code in the textarea below.

Introduced in CSS version
2.1
Inherited
N/A
Browser Support
BrowsersIEFirefoxSafariOperaChrome
Versions71160.2
Belongs to:

See the full list CSS properties and browser support: CSS Properties