html - Select elements by data attribute in CSS -


It is possible to select elements in CSS using their HTML5 data properties (for example, the data- Roll

If you want to use one, make sure, why not: < / P>

  [data-role = "page"] {/ * Styles * /}   

Different selectors can use you for different scenarios, which All documents include I make notes to link Keep in mind that, despite the custom data attributes being "the new HTML5 feature",

  • Browsers generally have no problem supporting non-standard features, So you should be able to filter them with attribute selectors;

  • You do not have to worry about CSS validation, because CSS non-namespace attribute names Does not care, h They broke no selector syntax.

Comments