Rigotti
Rigotti

Reputation: 2862

Any selector for checking if an attribute name starts with a value?

I know you can select the elements if the attribute exists

[data-value] { /* rules */ }

Or that its values starts with some val

[data-value^="foo"] { /* rules */ }

But, can I check if any elements contain contains a prefixed attribute?

[^data-] { /* something like it? /*}

This question came when I was trying to query all attributes of the page that has a prefixed aria atrittube. eg. aria-hidden, aria-live...

Upvotes: 1

Views: 265

Answers (1)

musefan
musefan

Reputation: 48415

Unfortunately it is not possible to do what you want with just CSS selectors, you would have to specify each attribute that you want to include. For example:

[aria-hidden], [aria-live]
{
}

It would be possible however to do something with javascript, so you may want to look into that if it's an option for you.

Upvotes: 1

Related Questions