CSS:
form input:not([type='button']),form input:not([type='submit']) { width: 200px }
HTML:
<form>
<input type='button' value='button' />
<input type='submit' value='submit' />
<input type='text' value='text' />
</form>
Demo: http://jsbin.com/imibew/edit#javascript,html,live
Issue: all input elements are getting width of 200px, where I just want the input of type text to have 200px.
Quirk: if you just list one selector in the , and not have a comma separated list, it works correctly.
Question: can I use commas when using :not()’s in CSS? Using lists in the selector seems to break it.
The comma represents a logical OR in selector syntax. Each element will thus be matched against each part of your selector at a time, and if it satisfies at least one of those parts, the rule is applied.
So in your case, this is what happens:
The
input[type='button']will match yourform input:not([type='submit'])selectorThe
input[type='submit']will match yourform input:not([type='button'])selectorThe
input[type='text']will (obviously) match both selectorsThat’s why your rule gets applied to all your form inputs.
If you want to combine both negations, chain them like so, instead of using a comma-separated list: