I have a text box, which acts as a search box on my page. I pre-populate the field with the word 'SEARCH' which has a default text colour of #D6D6D0.
Using CSS, is it possible to change the text colour to #FFFFFF when someone enters text in the box?
<input type="text" name="q" value="SEARCH" id="searchFieldText">
#searchFieldText {
background: url("/images/crmpicco/search_bg3.png") no-repeat scroll 0 0 #000000;
border: medium none;
color: #D6D6D0;
float: left;
font-family: Arial,Helvetica,sans-serif;
font-size: 10px;
height: 21px;
padding-left: 0;
padding-top: 3px;
width: 168px;
}
You can also use the RGB decimal equivalent or the color name. For example, if you change the textbox background color to say, blue, you could specify any one of the following: background-color:blue; , background-color:#0000FF; , background-color:rgb(0,0,255); .
Simply add the appropriate CSS selector and define the color property with the value you want. For example, say you want to change the color of all paragraphs on your site to navy. Then you'd add p {color: #000080; } to the head section of your HTML file.
The focus pseudo class should work
#searchFieldText:focus {
color: #fff;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With