Sometimes, we want to select elements by attribute in CSS.
In this article, we’ll look at how to select elements by attribute in CSS.
How to select elements by attribute in CSS?
To select elements by attribute in CSS, we use the attribute selector.
For instance, we write
[data-role="page"] {
/* Styles */
}
to select all elements with the data-role
attribute set to page
.
Conclusion
To select elements by attribute in CSS, we use the attribute selector.