Click here to join our Email List

How can I add a Google search box to my web site?

Using the following 2 code options, you can add a Google search box that will either search your own web site or the entire web.

Option 1:

Here's a Google search form that lets the user alternate between just your site (well, in this case just my site) or the entire Web:

<form method="get" action="http://www.google.com/search">
<input type="text" name="q" size="31" maxlength="255" value="" />
<input type="submit" value=" Google Search" />
<input type="radio" name="sitesearch" value="" /> Web search
<input type="radio" name="sitesearch" value="pctutorweb.com" checked /> Search PCTUTOR<br />

</form>

The above code will give you the following search box:

Web search Search PCTUTOR

Just copy and paste the red code above from the <form  to the closing </form>   into your web page in code view. Then swop my domain name pctutorweb.com with yours, and Search PCTUTOR to your name.


Option 2:

Here are some additional tweaks we can apply to make it a bit more fancy, including changing the radio buttons to a single check box, and aligning things a bit more nicely using a table and some simple CSS:

<form method="get" action="http://www.google.com/search">
<div style="border:1px solid black;padding:4px;width:20em;">
<table width="300" border="0" cellpadding="0">
<tr><td><input type="text" name="q" size="25" maxlength="255" value="" />
<input type="submit" value=" Google Search" /></td></tr>
<tr><td align="left" style="font-size:75%"> <input type="checkbox" name="sitesearch" value="pctutorweb.com" checked />
<span class="style3">only search PCTUTOR</span><br />
</td></tr></table></div>
</form>
Here's how that renders when included on an HTML page:

only search PCTUTOR
Just copy and paste the red code above from the <form  to the cloding </form>   into your web page in code view. Then swop my domain name pctutorweb.com with yours, and Search PCTUTOR to your name, or "only search this site".

Enjoy!

pctutorweb.com