Free Search Box with Style

A good looking search box can give your site an extra kick. A lot of sites have stylish search boxes with an eye catching search icon for the submit button.

Some examples of these sites are digg.com, live.com, and cnet.com.

If you would like to save some time, it is good practice to reuse certain web design elements. In this short tutorial you will learn how to quickly create a search box that is easy to do and visually appealing.

Note
The code for this search box is designed for wordpress, but could be easily modified to work with another cms.

I’ve used a search box like this one on many cms’s including Pligg, PhpBB and Wiki-Media.

You must have a valid doctype
Here is a list of valid doctypes.

I’m not going to explain what each particular part of the code does because it’s pretty self explanatory.

The xhtml

<div class="search-box">
<form method="get" action="<?php bloginfo('url'); ?>/">
<input type="text" size="15" class="search-field" name="s" id="s" value="Search.." onfocus="if(this.value == 'Search..') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Search..';}"/>
<input type="submit"  value="" class="search-go" />

</form></div>

The css

form{margin:0;padding:0}

.search-box{ /*outer background*/
background:url(images/search-box.gif) no-repeat top left;
height: 26px;
padding: 5px 0 0 10px;
width: 165px;
}

input.search-field{ /*input field */
float: left;
border:0;
margin:0;
font-family:tahoma;
font-size: 12px;
padding: 3px 0px 0px 4px;
height:18px;
background: #ffffff url(images/search-form.png) no-repeat top left;
width: 123px;
}

input.search-go { /*search icon */
float:left;
border:0;
margin:0;
padding:0;
margin-left: 5px;
height: 21px;
width: 21px;
background: url(images/search-icon.png) no-repeat top left;
cursor: pointer;
}

input.search-go:hover{ /*search icon hover "Does Not work in ie6" */
background:url(images/search-icon.png) no-repeat bottom left;
}

The Images Used

Source Image for search icon

Feel free to make comments and leave trackbacks.

Posted in Tips & Code
Tags: , , ,

30 ResponsesComments Feed

  1. mick

    This is exactly what I was looking for!

    09/15/08, 1:03 pm
  2. Very nice and neat 2.0 search box, i think i will use this on my sites.
    thanx.

    09/15/08, 2:31 pm
  3. Hi,
    sorru i fixed it, but will it work in ie6?
    Cheers

    10/14/08, 12:57 am
  4. Hi there,
    I tested it on IE 6. I does not completely works.
    Although you can see the search box and the graphics but when you hover over the search button you don’t see the button turn blue like it does on other better quality browsers.I think this is good enough.
    I am trying to implement it with my custom search engine made by Smart Spidey (http://www.smartspidey.com) for my website.

    -Gates

    11/25/08, 8:38 pm
  5. qkinweb

    Yes the hover does not work in ie6. I commented that it does not work in ie6 in the css.

    11/27/08, 11:30 am
  6. Thanks bro! I will have up on my website in a couple days. It was as easy as copy and paste. Take care.

    01/12/09, 4:53 pm
  7. excellent, i would also like to see more such releases from you!!!!!!!!

    03/11/09, 2:48 pm
  8. Man, I can’t wait to plug this into the redesign I’m concocting. Eric Watson (commenter above) steered me to this via SitePoint. Nice job!

    For the record, I don’t give a d@mn if the hover doesn’t work in IE6, though if you guys do concoct a fix I’d be glad to hear about it.

    04/12/09, 12:33 am
  9. For more web designing related you may also visit http://owebdesigner.com . its my favourite

    12/25/10, 6:55 am
  10. Thanks. Will be looking for more stuff from you.
    I have used the style and design on my website

    03/12/11, 6:46 am
  11. moliate

    This change will make the hover work in IE6:

    input.search-go:hover,
    search input.hover{
    background:url(../images/search-icon.png)
    no-repeat bottom left;
    }

    03/31/11, 10:20 am
  12. moliate

    no, it will not.

    Sorry about that – I had an IE7 open at the same time and looked at the wrong window. Made a typo in the post above anyway…

    03/31/11, 10:28 am
  13. Fred

    Very nice…
    Have already used your code with my own modified images (based on yours).

    04/26/11, 10:58 pm
  14. this is just a test!!! Hello SEO world!

    08/15/11, 12:35 am
  15. Thought I would comment and say awesome theme, did you create it yourself? It looks superb!

    08/18/11, 5:03 am
  16. Excellent search box. Some minor adjustments will get it working in IE6 (png and hover). Great experience.

    01/09/12, 9:10 pm
  17. Very nice !THX

    05/18/12, 5:20 am
  18. I’m worth it to read in this topic i do hope you will elaborate read more about it in future posts

    05/20/12, 11:28 am
  19. Its wise to participate in a contest for the most effective blogs on the internet. I most certainly will advocate this amazing site!

    05/20/12, 11:28 am
  20. You’ll find certainly a number of details that way take into consideration. It really is a nice level to make up. I supply the ideas above as normal inspiration however clearly there are actually questions such as the one you start up in which a extremely powerful factor are going to be doing work in trustworthy good faith. I don?t know if finest practices have emerged around issues that adheres to that, but Im sure your job is clearly recognized as a fair game. Both youngsters sense the impact of just a moment’s pleasure, through out their lives.

    05/20/12, 11:29 am
  21. Really good write-up,reasonable advice. With bless you =)

    05/20/12, 11:29 am
  22. You will be effective at do your audio alone, no need to inquire your buddies guide while youre repairing your beats.

    05/20/12, 11:29 am
  23. Heya my business is for the first time hereI found this board i to get It genuinely useful & it forced me to be out muchI want to provide a very important factor back and aid others that you aided me.

    05/20/12, 11:30 am
  24. YouTube was began in 2005 by 3 PayPal workers furthermore, as then YouTube has expanded to on the list of biggest webpages in the world. Youtube Currently has over 1 billion page views on a monthly basis Well as over 1 Billion Unique Page Views Per month.

    05/20/12, 11:30 am
  25. Nice site, looks very organized. Finally found what Ive been trying to find, thanks!

    05/20/12, 11:32 am
  26. Hi, can anyone help me join your blog post? I like it, thanksCu

    05/20/12, 11:32 am
  27. Your blog came up in my research that i’m taken in regards to what you may have written during this topic. I will be presently extending my enquiry and so cannot contribute further, nonetheless, I’ve bookmarked your internet world post and here we are at match any next updates. At the moment adore it and give thank you for tolerating my remark.

    05/20/12, 11:32 am
  28. Please email me with any hints on the way you have made your web blog look this awesome, I would personally be appreciative!

    05/21/12, 5:45 am
  29. How you can extend the plethora of the Wireless N router? Concerning an Xtreme N cellular router (Dlink). I would extend the reach through the wireless signal. I have learned to do it for your G signal. I have to understand how to do this for the N signal. Can you really apply regular N routers as repeaters. If so, how will you configure them. Thanks for any information.

    05/21/12, 5:50 am

Leave a Reply

Your email address will not be published. Required fields are marked *