Lets say I have CSS like this:
div.form label input {
/* some css here */
}
However this will apply to all of my input elements. I want to have another CSS that applies to an input type, so how do I do this? Creating a class won’t work here because it will just be ignored because of this first one.
Use case:
I have 5 text input that I want to style x way and I have 3 text input that I want to style y way.
Use the attribute selector, supported by IE7+, and every other modern browser..
If you want, say, text inputs, use this:
Inputs of type
passwordwould be like this, for example:And so on. It’s not used that often, but should be, to use other attributes and even custom ones. This quirksmode page gives good examples.
Here is one of my own:
If we’re applying this to
textinputs, you can use theirnameattribute: