The great thing about this is that with just a little effort and not much code you can make a functional search box that matches your blogs design.
Lets jump right in.
Our original code for the search form should look like this.
<form action="/search" id="searchthis" method="get" style="display: inline;"><input id="search-box" name="q" size="30" type="text" /> <input id="search-btn" type="submit" value="Search" /></form>
The form should look like this -
• • • • •
How to change the "execute search" button
Using the code from above. First delete the codevalue="search"
.Then change
type="submit"
to type="image".
Not to be confused with type="text"
found earlier in the form. Don't delete that. Next, add your image by adding the code
src="IMAGEURL.PNG"
before the type="image"
but after id="search-btn"
.Now you'll want to align the image by adding
align="top"
before the id="search-btn"
code but after the input
code. This is not necessary but if you having alignment issues adding this could be the solution.The form should now look like something like this - depending on the image you used.
and your code should look like this
<form action="/search" id="searchthis" method="get" style="display: inline;"><input id="search-box" name="q" size="30" type="text" /> <input align="top" id="search-btn" src="IMGURL.png" type="image" /></form>
Note:
If you are in need of an image to use I have this one and this one .
The url for the first is
and the url for the second is
for more search buttons do a quick internet search, you'll find thousands of ideas.
If you are in need of an image to use I have this one and this one .
The url for the first is
http://i1251.photobucket.com/albums/hh552/lovinglifedesigns/SearchButton.png
and the url for the second is
http://i1251.photobucket.com/albums/hh552/lovinglifedesigns/search_btn.png
for more search buttons do a quick internet search, you'll find thousands of ideas.
• • • • •
How to change the Border and Background colors of the search form
This one is pretty easy. All you need to do is add an inline style to the search form. I've added it after thename="q"
and before the size="30"
codes.Example 1 -
In this first example I added a red dashed border by adding the following code
style="border: 1px dashed red"
Example 2 -
In this example I added a purple border and a pink background by added the following code
style="border: 1px dashed #8d38c9; background:#FAAFBA;"
Example 3 -
In this last example I added a goldenrod background by added the following code
style="background:#FAAFBA;"
My completed form code for example 3 looks like this:
<form action="/search" id="searchthis" method="get" style="display: inline;"><input id="search-box" name="q" style="background:#FAAFBA;" size="30" type="text" /> <input id="search-btn" type="submit" value="Search" /></form>
Here are some useful resources to help with color and border properties.
- For more information on CSS borders take a look at this tutorial by W3Schools .
- For more information on HTML color codes take a look here at computer hope .
- For ideas on color combinations take a look here at colorlovers web trends.
• • • • •
How to Change the Text Properties of the search form
To change your text properties, like changing the text color or making the text uppercase, you again need to add an inline style to the search form.To change the text transformation add
text-transform:uppercase;
.Example 1 -
To change the text color you need to add a
color: #HTMLCODE;
.Example 2 -
*Remember you need to add words to the search box in order for this option to work. You can learn about that from my last tutorial.
My completed search form code for the above example looks like this:
<form action="/search" id="searchthis" method="get" style="display: inline;"><input id="search-box" name="q" style="text-transform:uppercase; color:#c38ec7;" size="30" type="text" value="keyword search" /> <input id="search-btn" type="submit" value="Search" /></form>
Here is a great resource on text properties from HTML help.
There you have it folks a simple, totally customizable, yet powerful search function. I hope that this tutorial is helpful. Please let me know if you have any questions I will be happy to try and help.
Happy Coding.