Here is my HTML:
<input type='submit' class='clsname'>
This CSS makes a blue border for that input: Demo
input{
border: 1px solid red;
}
.clsname{
border: 1px solid blue;
}
But this makes a red border for that input: Demo
input[type='submit']{
border: 1px solid red;
}
.clsname{
border: 1px solid blue;
}
I don't know why exactly, But I know it is related to the priority of selectors. I think input[type='submit'] has a bigger priority than classname, but input doesn't have a bigger priority than classname.
Now I have a selector like this: input[type='submit'] and I need to give a bigger priority to class name. How can I do that? I mean something like this:
input[type='submit'] { }
.clsname { /* bigger priority here */ }
Note: I can do that by !important, But I want to know is there any approach else? Because using !important is not recommended.
input[type='submit'].clsname, .clsname. Fiddle