Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

More elegant way to express a CSS selector

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.

like image 830
RockPaperLz- Mask it or Casket Avatar asked Nov 20 '25 14:11

RockPaperLz- Mask it or Casket


2 Answers

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).

like image 111
BoltClock Avatar answered Nov 22 '25 07:11

BoltClock


You can try

input:not([type="image"], [type="submit"])

but your selector match is better.

like image 42
Stanimir Dimitrov Avatar answered Nov 22 '25 07:11

Stanimir Dimitrov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!