CHAPTER 4

image

Attribute selectors

Attribute selectors allow style to be added to elements based on their attributes and attribute values.

Attribute selector

The attribute selector will match elements that use the specified attribute, regardless of its value.

input[type] {}

This selector will match only input elements that use the type attribute, such as the following element:

<input type="text">

Attribute value selector

The [attribute=value] selector will match by both attribute and value.

input[type="submit"] {}

Input elements that have their type attribute set to submit will be matched by this rule, as in the following example:

<input type="submit"> ...

Get CSS Quick Syntax Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.