Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Attribute selector alternative

Status
Not open for further replies.

philote

MIS
Oct 2, 2003
861
US
I've never really styled form elements before and just started adding styles to a form with a bunch of text fields and one submit button. I started out with something like this:
Code:
input{
 background-color: gray;
 border: 1px solid blue;
}
But this of course style my submit button, and I'm assuming it would also style any other inputs whether they were text fields or not. I found that you could (according to CSS standards) also specify an attribute selector to match attributes for an element:
Code:
input[type=text]{...

This of course didn't work in IE (but does in Mozilla). So my question is, what is a better way to apply a style to just one type of form input. Assign all the inputs to a class? Assign the submit button to a class or id and override the input style I defined? I don't really like either of these options so I'm hoping there's a better way that is compatible in most browsers.

Kevin
A+, Network+, MCP
 
That's about it. You'd have to override it with an ID or Class option in your CSS/HTML code.

# HTML code
<form>
<input type=&quot;text&quot; class=&quot;input_field&quot;>
</form>

# CSS code
.input_field {
color: #cc33cc;
}

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top