Log in

View Full Version : Text field



viktor
07-09-2005, 01:26 AM
Can the text input field color be changed, I saw many websites and it didn't look like they used flash or java.
This is what the code is for the text input:
<input type="text" name="sString" size="20"/>
How can I change its color its white by default ?

jscheuer1
07-09-2005, 03:10 PM
Proper (in the head):

<style type="text/css">
input {
background-color:pink;
}
</style>The above will set the background color for all input tags on the page - buttons, radio buttons, checkboxes, text input.

Quick and dirty (this will only affect this tag):

<input style="background:pink;" type="text" name="sString" size="20">

viktor
07-09-2005, 11:28 PM
Thanks for the info, it works well. It also works if you put CSS style code in the body at least all the way in the beginning. I already changed color of textarea and option. Quick question, when I changed the color of OPTION the only thig that changes is the background of drop down list when you view it, it still appears white when it is not used, is there a way to change that or thats how it works ?


<style type="text/css">
option {
background-color:lightgreen;
}
</style>

mwinter
07-09-2005, 11:52 PM
It also works if you put CSS style code in the body [...]Only because modern browsers perform error correction. A style element is only valid in the head element within a document. Don't put them anywhere else.


I already changed color of textarea and option.Always make sure that you specify a foreground colour whenever you set the background (and vice versa). Desktop themes, for example, can change default colours to values that you might not expect and can render documents completely unreadable if you just assume that those defaults will be the same as they are on your computer.


Quick question, when I changed the color of OPTION the only thig that changes is the background of drop down list when you view it, it still appears white when it is not used, is there a way to change that or thats how it works ?Yes, that's how it works. Set a background colour for the select element, too:


<style type="text/css">
select,
option {
background-color: lightgreen;
color: black;
}
</style>Mike

viktor
07-10-2005, 06:21 PM
Only because modern browsers perform error correction. A style element is only valid in the head element within a document. Don't put them anywhere else.

Always make sure that you specify a foreground colour whenever you set the background (and vice versa). Desktop themes, for example, can change default colours to values that you might not expect and can render documents completely unreadable if you just assume that those defaults will be the same as they are on your computer.

Yes, that's how it works. Set a background colour for the select element, too:


<style type="text/css">
select,
option {
background-color: lightgreen;
color: black;
}
</style>Mike


Thanks, I got it now.