Help with a CSS selector that targets all elements that have "aria-*" attributes
Is it possible to target all elements that have an attribute with a specific prefix like "aria-"? I want to select all aria attributes like "aria-label", "aria-labelledby", "aria-level" and so on...
15 Replies
do you use sass?
if you do, make a list with all attributes
if not, do the work manually
you can use
:is()
, :where()
or repeat each selector manuallyyou could also do this using js by doing something like:
unless it is to use in css, for styles
yeah
you can only do that with values of the attribute i believe, not the name. e.g.
meaning it selects all elements that have the attribute of
data-test
with a value that starts with aria
i think to actually test if the name includes a substring you have to use jsthe challenge is to select anything that has an attribute starting with
aria-
it's the name of the attribute, not the valuei know
i was saying it in response to the error you posted
the error was to show it doesnt work
would be awesome if it did
yeah, i was just explaining why it didn't to benefit op and clevermissfox
oh, i though you misunderstood what i sent
i could have referred to the context in my message a bit better, that's my bad.
no, it's my bad too
i should pay more attention
it's all good, we got it in the end