CSS [attribute] Selector

Complete CSS Reference Complete CSS Reference

Example

How to style links, but only links with a target attribute:

a[target]
{
background-color:yellow;
}

Try it yourself »

Definition and Usage

The [attribute] selector styles elements with the specified attribute.


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The [attribute] selector is supported in all major browsers.

Note: For [attribute] to work in IE, a <!DOCTYPE> must be declared.


CSS Version

The [attribute] selector was first introduced in:

CSS 2


Related Pages

CSS tutorial: CSS Attribute Selectors


Complete CSS Reference Complete CSS Reference