How to style just one type of input field without also affecting other input types with CSS

Posted by James on Stack Overflow See other posts from Stack Overflow or by James
Published on 2010-06-12T23:27:12Z Indexed on 2010/06/12 23:32 UTC
Read the original article Hit count: 194

Filed under:
|

Is there a way to write style rules that will only influence text fields. Suppose I have the following:

<div id="helloDiv">
<input type="text" name="something" /><br />
<input type="checkbox" name="somethingElse" /><br />
<input type="submit" name="go" />
</div>

div#helloDiv input {
   border: 1px solid red;
}

The problem with the above CSS rule is that it will affect ALL input fields not just input text but also radio buttons, submit buttons, etc.

So is there a cross browser solution to affect just one type of input field within a div or other page element (without resorting to assigning the input fields styles individually).

© Stack Overflow or respective owner

Related posts about html

Related posts about css