Categories
CSS

How to select elements by attribute in CSS?

Spread the love

To select elements by attribute in CSS, we use the attribute selector.

For instance, we write

[data-role="page"] {
  //...
}

to select the elements with the data-role attribute equal to page.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *