The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS A question on form styling Re: A question on form styling

Rob MacKay

what I do is use a little jQuery:

<input type="text" name="search" value="Search…" id="search" />

then like…

$(function() {
//target search box when use focuses
$(“#search”).focusin(function() {

//Removes the value.


//listens for the focus out…
$(“#search”).focusout(function() {

//check if a user has added a value
if($(this).val()) {

// if they have – do nothing because you want to keep theirs

} else {

// If they have not, and the field is blank – add the value again…




That, although it’s the long way round code wise, should provide a solution that you can learn from :)