Welcome to WebmasterWorld Guest from 54.198.222.129

Forum Moderators: not2easy

Message Too Old, No Replies

Problem with :not( ) + attribute selector

     
10:34 am on Dec 24, 2012 (gmt 0)

10+ Year Member



So here's a super pared-down snippet of my code:

[jsfiddle.net...]

I have default styles for input that are in my header, and inputs that are not in my header. All is well, except IE applies styling to check boxes that all other browsers don't. So I want to exclude checkboxes from my default input style. But when I do this, the default input style then overrides the default header input style. And to make things more confusing, this is the selector:

input:not([type=checkbox])

However if I write that selector "wrong" like so: input:not(type=checkbox)
that works. It skips checkboxes, and it doesn't override header input boxes. But it's incorrect syntax. What is going on here? Any ideas?
1:13 pm on Dec 24, 2012 (gmt 0)

5+ Year Member



In wich IE version have you problems? Remember, :not just works on IE9 or later.
8:40 pm on Dec 24, 2012 (gmt 0)

10+ Year Member



Well the initial checkbox thing happens in IE9 and IE10. But the weird not behavior happens in all browsers.
10:22 pm on Dec 24, 2012 (gmt 0)

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



input:not([type=checkbox])

However if I write that selector "wrong" like so: input:not(type=checkbox)

Where did you get that the brackets are mandatory with :not? The CSS3 "Selectors" page doesn't say so, either explicitly or through their examples. If you did use brackets, I'd expect the form to be

input:not([CHECKBOX])

:: off to investigate ::
10:36 pm on Dec 24, 2012 (gmt 0)

10+ Year Member



All the examples show it in the form I used, with brackets. Plus the CSS validator complains when I don't have brackets.
4:47 pm on Dec 27, 2012 (gmt 0)

10+ Year Member



Hi,

input:not([type=checkbox]{} is working fine it must be some other conflict in your code. It's probably a specificity issue but we'd need to see some more relevant code.


However if I write that selector "wrong" like so: input:not(type=checkbox)
that works.


No it doesn't. The rule is simply ignored because it is invalid.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month