Selector by attribute name
An attribute name selector styles an element that has only the specified tag attribute.
Example
Let's select the <input> tag, with
the type attribute, and give it
a blue background color:
<p>
<label>Enter text</label>
<input>
</p>
<p>
<label>Enter number</label>
<input type="number">
</p>
input[type] {
background-color: #C2DDFD;
}
:
See also
-
an attribute selector
that searches for an element by attribute value -
an attribute selector
that searches for an element based on the start of an attribute value -
an attribute selector
that searches for an element based on the end of an attribute value -
an attribute selector
that searches for an element by text in an attribute value -
an attribute selector
that searches for an element based on one of attribute values -
an attribute selector
that searches for an element by a hyphen in an attribute value -
the child selector
that allows you to select elements by direct nesting -
the descendant selector,
that allows you to select an element by its parent -
the adjacent sibling selector
that allows you to select an element by its sibling -
the general sibling selector
that allows you to select elements after a given -
the universal selector
that allows you to select all elements