Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Universal CSS selector to match any and all HTML data-* attributes [duplicate]

Is it possible to match all nodes that have a data-* attribute using only CSS?

Here are examples of attributes I would like to match:

data-scope
data-sessionlink
data-visibility-tracking

I could do

*[data-scope] *[data-sessionlink] *[data-visibility-tracking]

but I am looking for something more compact. Furthermore, I don't know all possible data-* attributes I might encounter in my application.

like image 871
Vadim Avatar asked Oct 19 '22 10:10

Vadim


1 Answers

It is currenly impossible to use wildcard masks to select elements by an attribute-name part.

There is a recent thread in the [email protected] mailing list, where Simon Pieters from Opera has proposed a nice possible syntax that has got some acceptance in the thread, so there is a chance that it will become standard somewhen in the future:

x-admin-* { ... }
[data-my-*] { ... }
like image 83
Marat Tanalin Avatar answered Oct 28 '22 17:10

Marat Tanalin