English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

CSS Reference Manual

CSS @rules

Comprehensive List of CSS Attributes

CSS [attribute] Selector

Represents an element with an attribute named attribute.

Complete CSS Selector Reference Manual

Online Example

Select all <a> elements with the target attribute:

<!DOCTYPE html>
<html>
<title>Basic Tutorial Website (oldtoolbag.com)</title>/title>
<head>
<style>
a[target]
{
background-color:blue;
color:white;
}
</style>
</head>
<body>
<p>Links with the target attribute will be filled with a blue background:</p>
<a href="//www.oldtoolbag.com">oldtoolbag.com</a>
<a href="//www.baidu.com" target="_blank">baidu.com</a>
<a href="//www.pcjson.com" target="_top">pcjson.com</a>
<p><b>Attention</b> To make [<i> attribute </i>] in IE8and earlier versions must declare DOCTYPE.</ p>
</body>
</html>
Test and see ‹/›

Browser Compatibility

All mainstream browsers support [attribute] Selector.

Browser Compatibility

IEFirefoxOperaChromeSafari

All mainstream browsers support [attribute] Selector.

Note: [attribute] In IE8Running in the middle, must declare <!DOCTYPE> .

Related Articles

CSS Tutorial: CSS Attribute Selector/a>

Complete CSS Selector Reference Manual