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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Apply CSS to only Text input field 1

Status
Not open for further replies.

Streetdaddy

Programmer
Jun 10, 1999
161
0
0
AU
I would like to apply CSS formatting to all Text fields, but not checkbox and radio buttons. Is there a way to do this in CSS without having to add style parameter to every instance of radio button or checkbox?

I have tried INPUT.TEXT {...} but then no formatting was applied to anything! Miles

Those Micros~1 guys sure know what they doing!
 
INPUT.TEXT {...} means that the style should be upplied to all input elements with class="text". If you don't have such a class, no surprize that the style wasn't applied.

You can only use this in style:
input { ... }

But the style will be applied to ALL input tags, including buttons/images: <input type=button|submit|reset|image> and others like radios.
There's no way to separate them without using classes.
 
There is a newer feature of CSS (2) that will allow you to separate input types (however, currently not supported in IE):
Code:
input[type=&quot;text&quot;] {....}

Here's a reference describing it's use:
If you need cross-browser functionality, then Starway's suggestion of classes is the way to go.
 
Thanks Starway, I didn't realise I needed to add the the class to the text field. That's a bit less code than adding style parameters to each text field ;)

Cheers. Miles

Those Micros~1 guys sure know what they doing!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top