views:

989

answers:

4

Assuming it is possible with just CSS...but wanted to know if someone could share the code.

Guessing magnifying glass is background image, but need javascript to remove "search" on focus.

Also...how do you get it to submit when hitting "return" rather than needing a "search" submit button?

Thanks!

+7  A: 

View -> Page source.

Seriously, it's all there.

Craig Stuntz
+1  A: 

If you look at with firebug you would see the image is not inside the search field.

This can explain it better than me. http://blog.reindel.com/2007/08/13/howto-spruce-up-your-search-box-with-css-and-a-background-image/

jdelator
look again, it is. it is a background image placed in the text box with no repeat. the text is then padded left to make room.
Jeremy B.
+4  A: 

few questions there:

  1. Submit on return, if you put an input in a form, and have focus on said input, when you press enter the browser will by default submit the form.

  2. Text masking. you can do this easily in jquery or any other framework. essentially you will remove the text "search" on focus, but only that text so if there was something like "foo" it would not replace it.

for your text masking needs: text mask

Jeremy B.
+11  A: 
#hsearch .textbox {all.min....ss?v=2743 (line 1)
    background:transparent url(http://i.stackoverflow.com/Content/Img/search.png) no-repeat scroll left center;
    margin:0;
    max-width:230px;
    padding-left:16px;
}

...is the CSS selector for:

<input name="q" class="textbox" onfocus="if (this.value=='search') this.value = ''" type="text" maxlength="80" size="28" value="search">

I would recommend getting the Firebug addon for Firefox. It will make your life much easier.

Tom
IE 8 view source is actually pretty good too.
rism
concur on Firebug
Benry