views:

102

answers:

4

Hi there. I've got quite big trouble, because i need to anathematise from styling some input types. I had something like:

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

But i don't want to style checkboxes too.

I've 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 I'll need to use || soon, and I think that usage will be same.

Thanks.

Update: I still don't know how to use || and && correctly. I couldn't find anything in W3 docs.

Last update:

Thanks, now I know something more, and I won't use them never. And I'll change :not

A: 

I guess you hate to write more selectors and divide them by a comma?

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

and BTW this

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

looks to me more like "input which does not have both these types" :)

Jaroslav Záruba
That wouldn't work, because the first selector would select all non- `radio`, (but _would_ select the `checkbox`), and the second would do the reverse. The union of the two would contain both `checkbox` _and_ `radio`.
Eric
Dan F
You're wrong. Then, first one will apply to second, and second, to first.
Misiur
you're right :)
Jaroslav Záruba
+5  A: 

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"])
KennyTM
Nah, fail too. It'll apply 1 to 2 and 2 to 1
Misiur
@Misiur: I don't understand.
KennyTM
@KennyTM: Look. Using comma will do something like this: .registration_form_right input:not([type="radio"]) will apply to everything including checkbox, and .registration_form_right input:not([type="checkbox"]) will apply to everything, including radio
Misiur
@Misiur: Of course. The 2nd is for the "OR" (a.k.a. `||`) case. Updated to clarify.
KennyTM
@KennyTM: What Misiur is trying to say is… Your "||" example is syntactically correct, but if you simplify the expression, it becomes just ".registration_form_right input" because the union of the two selectors includes all inputs.
geofflee
@geo, @Mis: look, the *question* asked "I'll need to use || soon", so this is a way to construct a `||` out of the examples. Of course it becomes `.registration_form_right input` after simplification, but the essence is *you use the `,` as `||`*. You could use `input:not([type="radio"]), input:not([name="foo"])` for a nontrivial example.
KennyTM
+3  A: 

The :not pseudo-class is not supported by IE. I'd got for something like this instead:

.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 there, but it's a small price to pay for higher compatibility.

Max Shawabkeh
You're quite right. Hovewer, best is adding class to input.
Misiur
+6  A: 

"&&" works by stringing-together multiple selectors like-so:

<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 like-so:

<div class="class1"></div>
<div class="class2"></div>

div.class1,
div.class2
{
  /* foo */
}

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

-Geoffrey Lee

geofflee
Ok, thanks for light. I hate styling forms, but it's my task, and site isn't mine. I'll apply classes to inputs.
Misiur
Here's a useful chart of what Internet Explorer supports: http://msdn.microsoft.com/en-us/library/cc351024(VS.85).aspx#selectors
geofflee