CSS "and" and "or"

I have very big problems because I need to anathematize the styling of some input types. I had something like:

.registration_form_right input:not([type="radio") { //Nah. } 

But I do not want to create flags either.

I tried:

 .registration_form_right input:not([type="radio" && type="checkbox"]) .registration_form_right input:not([type="radio" && "checkbox"]) .registration_form_right input:not([type="radio") && .registration_form_right input:not(type="checkbox"]) 

How to use && ? And soon I will need to use || , and I think the usage will be the same.

Update:
I still donโ€™t know how to use || and && . I could not find anything in the W3 docs.

+58
css conditional-operator css-selectors
May 9 '10 at 8:42 a.m.
source share
7 answers

&& works by combining several so-type selectors:

 <div class="class1 class2"></div> div.class1.class2 { /* foo */ } 

Another example:

 <input type="radio" class="class1" /> input[type="radio"].class1 { /* foo */ } 

"||" works by separating multiple selectors with commas, for example:

 <div class="class1"></div> <div class="class2"></div> div.class1, div.class2 { /* foo */ } 

As a side note, I would recommend not using the no selector because it is not supported by Internet Explorer. Based on one survey, 60% of people use some version of Internet Explorer, so your site will not work for many people.

+77
May 09 '10 at 8:59
source share

And ( && ):

 .registration_form_right input:not([type="radio"]):not([type="checkbox"]) 

OR ( || ):

 .registration_form_right input:not([type="radio"]), .registration_form_right input:not([type="checkbox"]) 
+26
May 9 '10 at 8:48 a.m.
source share

To select the a AND b properties of an X element:

 X[a][b] 

To select the a OR b properties of an X element:

 X[a],X[b] 
+5
Dec 20 '16 at 21:50
source share

Class pseudo-class :not supported by IE. Instead, I would get something like this:

 .registration_form_right input[type="text"], .registration_form_right input[type="password"], .registration_form_right input[type="submit"], .registration_form_right input[type="button"] { ... } 

Some duplication is there, but it's a small price to pay for higher compatibility.

+3
May 09 '10 at 8:52 a.m.
source share

I think you hate writing more selectors and separating them with a comma?

 .registration_form_right input:not([type="radio"]), .registration_form_right input:not([type="checkbox"]) { } 

and BTW is

 not([type="radio" && type="checkbox"]) 

looks at me more like "an input that does not have both of these types" :)

0
May 9 '10 at 8:46 a.m.
source share

Just in case someone is stuck like me. After you sent the message, and some hits and trials it worked for me.

 input:not([type="checkbox"])input:not([type="radio"]) 
0
Feb 19 '14 at 19:09
source share

You can somehow reproduce the "OR" behavior using and and: not.

 SomeElement.SomeClass [data-statement="things are getting more complex"] :not(:not(A):not(B)) { /* things aren't so complex for A or B */ } 
0
Oct 27 '14 at 11:46
source share



All Articles