Gotcha???
Main Topics
Browse All TopicsHow can I apply style to input textbox field with CSS?
I would like to avoid inline formating for every field since they are all same.
If I need to apply additional style for some field, will it be completly overwriten or just "appended"?
Thanks!
For example.. this style: style="font-family: Verdana; font-size: 7pt; border: 1 solid #000000;"
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Hi,
With:
<form action="foo" method="post">
...
<input type="text" name="foo" value="" />
<input type="text" name="foo" value="" style="font-size: 8pt;" />
<input type="text" name="foo" value="" class="pretty" />
<input type="text" name="foo" value="" class="pretty" style="font-size: 8pt;" />
...
</form>
The first input tag will take whatever the default style for input tags is (see style element "input" below).
The second input tag will use the inline CSS style information you have supplied it with (overriding the default "input" style element).
The third input tag will use CSS styles from the "input.pretty" style element (see below).
And finally the fourth input tag will use the CSS styles from the "input.pretty" style element, with the "font-size" attribute overriden by the inline style you've supplied it with.
Here's the style sheet which can either be included inline (as below), or as an external file (by using: <link rel="stylesheet" type="text/css" href="styles.css" /> in your <head>...</head> section):
<style type="text/css">
input
{
font-size: 10pt;
}
input.pretty
{
color: green;
background-color: transparent;
}
</style>
Note that in the stylesheet above, the input.pretty inherits the "font-size" information defined in the default "input" style.
Cheers,
-- Jeex
Actually, to make it clearer, style information cascades rather than being overwritten unless the same attribute is used. I.e., in the example above:
<input type="text" name="foo" value="" class="pretty" style="font-size: 8pt;" />
translates to:
font-size: 8pt; (overrides the default 10pt)
color: green;
background-color: transparent;
Hope that makes things clearer!
-- Jeex
Found this elsewhere which may clear up some confusion for those looking at stylesheets. rsahi's anwer and jeex's will work but any generic styles (anything in input {...}) will also affect any other input fields like checkboxes.
"input[type="text"] is the correct CSS, but this won't work in Internet
Explorer.
The only real solution is to apply a class to all your textboxes, such as
class="text" and then style .text as you would like."
Business Accounts
Answer for Membership
by: rsashiPosted on 2003-05-13 at 04:24:48ID: 8515705
save it as .css file
INPUT
{
FONT-SIZE: 7pt;
BORDER-LEFT-COLOR: #666666;
BORDER-BOTTOM-COLOR: #666666;
BORDER-TOP-COLOR: #666666;
FONT-FAMILY: Verdana;
BORDER-RIGHT-COLOR: #666666
}
and with in html file add this on top
<LINK REL="stylesheet" TYPE="text/css" HREF="file.css">