Charles John Thompson III Charles John Thompson III - 27 days ago 5
CSS Question

CSS multiple input[type] selectors

According to the W3 CSS spec, something like:

input[type~="text password"]
should select input fields whose type is set to either "text" or "password", but it doesn't work! Did I misinterpret this line?

E[foo~="warning"] Matches any E element whose "foo" attribute value is
a list of space-separated values, one of which is exactly equal to

CSS spec source, it's the fourth from the bottom in the table.


Yep, you've got it round the wrong way. The selector is to search within a space seperated list.. i.e.

<element attribute="text password" />

you could find using:


The benefit of this is that it shouldn't match:

<element attribute="textual password" />

Hope that helps?

To achieve what you're actually trying to do is a bit more verbose:

input[type="text"], input[type="password"]