If they exist in programming),
If I have an HTML form with the following inputs:
<input type="text" />
<input type="password" />
<input type="checkbox" />
I want to apply a style to all inputs that are either type="text"
or type="password"
.
Alternatively, I would settle for all input's where type != "checkbox"
.
It seems like I to have to do this:
input[type='text'], input[type='password']
{
// my css
}
Isn't there a way to do:
input[type='text',type='password']
{
// my css
}
or
input[type!='checkbox']
{
// my css
}
I had a look around, and it doesn't seem like there is a way to do this with a single CSS selector.
Not a big deal of course, but I'm just a curious cat.
Any ideas?
That is the correct way to do it. Sadly CSS is not a programming language.
CSS3 has a pseudo-class called :not()
Multiple selectors
As Vincent mentioned, it's possible to string multiple
:not()
s together:CSS4, which is not yet widely supported, allows multiple selectors in a
:not()
Legacy support
All modern browsers support the CSS3 syntax. At the time this question was asked, we needed a fall-back for IE7 and IE8. One option was to use a polyfill like IE9.js. Another was to exploit the cascade in CSS: