Is there a more elegant way to write the following CSS selector?
input:not([type="image"]):not([type="submit"])
I want to match all HTML input elements that are not of type image or of type submit.
Target browser is only Firefox, so Mozilla CSS extensions are fine.
Is there a more elegant way to write the following CSS selector?
No, there isn't. Firefox 3 previously allowed :not() to contain any number of selectors which would have allowed you to write
input:not([type="image"], [type="submit"])
but that was technically a bug as the syntax wasn't in any standard at the time, and it no longer works in any major release since. It's now in Selectors 4, though, so hopefully it'll return soon.
Selectors 4 also contains :matches(), which is implemented in Firefox as :-moz-any(), however you can't use that as it doesn't accept negations (seeing as :not() will have the same expanded syntax anyway, it doesn't make sense to have each allow the other, but then you wonder why they didn't implement a :-moz-not() to go with it).
You can try
input:not([type="image"], [type="submit"])
but your selector match is better.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With