Sometimes, we want to apply a CSS style to an element with the given name.
In this article, we’ll look at how to apply a CSS style to an element with the given name.
How to apply a CSS style to an element with the given name?
To apply a CSS style to an element with the given name, we use the attribute selector.
For instance, we write
<input name="goButton" />
to add an input with the name
attribute set to goButton
.
Then we write
input[name="goButton"] {
background: red;
}
to select the input with the name
attribute set to goButton
with input[name="goButton"]
.
Conclusion
To apply a CSS style to an element with the given name, we use the attribute selector.