CSS Selector [attribute]

Description

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

Example


<!DOCTYPE html>
<html>
<head>
<style>
a[target]<!--from  w w w . j  ava 2s. com-->
{
   background-color:red;
}
</style>
</head>
<body>
   <a href="http://java2s.com" target="_black">java2s.com</a>
</body>
</html>

Click to view the demo

The code above generates the following result.

[attribute]




















Home »
  HTML CSS »
    HTML CSS Reference »




HTML Tag Reference
CSS Reference
CSS Selector Reference
Encoding Reference