danarj danarj - 5 months ago 20
CSS Question

stop applying css selector for one element

I want to prevent this CSS selector from being applied to all elements in the page:

input {
color:red;
}


This will make the text red for
<input>
s of every type, but I want to exclude one input from this without changing the selector or style of this CSS rule. The element should have the default style (how it is when you have no css on the page).

Answer Source

You can use the not selector. Since an input field should have a name, you could exclude it by using:

input:not([name="exludeme"]) { }

This method won't work in IE8 and earlier versions. To support ie7 and ie8 too, you could use the attribute selector. In this case you have to reset the field:

input[name="exludeme"] { /*add all your reset styles here*/ }