Reputation: 40140
input type=text/radio/checkbox - can I treat them differently in my CSS?
Other than by adding class=
I mean
Upvotes: 6
Views: 6062
Reputation: 11
You can use
input[type="What ever the type you want to style specifically"]
Upvotes: 1
Reputation: 555
You can use the attribute selector, like this
input[type=text] { ... }
However, this is not supported in all browsers. Your safest bet is to use a class
Upvotes: 5
Reputation: 67194
YES!
With an awesome thing called attribute selectors:
input[type="text"] { width: 200px; }
Just change that text
there and you're good to go!
But note that these don't work on IE6, so you might want to take a look at the dean.edwards.name IE7.js :)
Upvotes: 14
Reputation: 14873
Yes you can
eg
input[type="text"]{
/*do something*/
}
and more
input[type="text"] {
font:bold 10px/12px verdana,arial,serif;
padding:3px;
}
input[type="button"],input[type="submit"] {
/* you know what to do */
}
Upvotes: 3
Reputation: 23255
You can use input[type=text]
to do this. Old browsers might not support it though.
Upvotes: 4
Reputation: 15567
I've never seen this done (and I've personally tried). I believe you would have to have some JavaScript/jQuery run on the page post render to manipulate the classes of objects based on element attributes.
Upvotes: 0