How to create a label inside an <input> element and style it?

cyber kamikaz

New Member
I can make my label inside an input element (my "disappearing text"):HTML\[code\]<input name="firstName" type="text" maxlength="40" value="http://stackoverflow.com/questions/15672970/Enter your first name" onfocus="if(this.value=http://stackoverflow.com/questions/15672970/=this.defaultValue)this.value=''" onblur="if(this.valuehttp://stackoverflow.com/questions/15672970/=='')this.value=http://stackoverflow.com/questions/15672970/this.defaultValue" />\[/code\]Then style it so my disappearing text is faded (#333). And style it so when I start to input a value into the field the text is black (#000).CSS\[code\]input[type=text] { color: #333;}input[type=text]:focus { color: #000;}\[/code\]It all works fine until you move onto the next input field. Then the field you just entered a value in changes back to the \[code\]#333\[/code\] color. I can see why that happens, but can't quite get to how to keep the value black \[code\]#000\[/code\] color if the input field has had a value put into it.Thanks in advance for the assist and education!
 
Back
Top