Industry guru Dave Taylor offers free tech support on a wide variety of technical and business topics, including HTML, online advertising, Cascading Style Sheets, Web design, management, Unix, Linux, search engine optimization, online dating, Mac OS X, shell script programming and Microsoft Windows.

Can the Google AdSense Search Tool background be changed?

Dave, how do I remove the "white" background color from the Google Adsense Search toolbar since it isn"t a gif or jpg picture as is your "Ask Dave" icon? Thanks!


Dave's Answer:

Digging around in the Google world, I've decided that you're talking about what Google calls the Adsense Search Box, not the Google Toolbar, because the latter has no relationship to the AdSense program, as far as I can tell. Which means that for this answer to have any meaning, you'll need to have already signed up for an AdSense account. But you probably should anyway, because even if it's just $20/month, you could be earning a few dollars from your Web site instead of always paying, paying, paying for hosting!

Advertisement over. Let's get down to specific details!

To get to the Google AdSense search box, you need to log in to AdSense, then click on "Search Settings", which will give you a pretty complex configuration form to fill out that includes "search box background color", though the only choices are white, black and gray. We can do better than that, however!

Here's the default Google search box configured for my own account (which is kinda cool: if you search with it, then click on one of the resultant ads on the results page, I'll see a small % of the transaction.):

Google

There's a lot of code there to look at:

<!-- Search Google -->
<center>
<form method="get" action="http://www.google.com/custom" target="_top">
<table bgcolor="#cccccc">
<tr><td nowrap="nowrap" valign="top" align="left" height="32">
<a href="http://www.google.com/">
<img src="http://www.google.com/logos/Logo_25gry.gif" border="0" 
  alt="Google" align="middle"></img></a>
<input type="text" name="q" size="40" maxlength="255" value="">
  </input>
<input type="submit" name="sa" value="Search"></input>
<input type="hidden" name="client" value="pub-7950118917489847"></input>
<input type="hidden" name="forid" value="1"></input>
<input type="hidden" name="channel" value="9514164789"></input>
<input type="hidden" name="ie" value="ISO-8859-1"></input>
<input type="hidden" name="oe" value="ISO-8859-1"></input>
<input type="hidden" name="hl" value="en"></input>
</td></tr></table>
</form>
</center>
<!-- Search Google -->

The key elements for what we want to tweak, however, are associated with the table that's used to wrap all the content. You can see it on line four: <table bgcolor='#cccccc'>. That sets our grey background. So, to change it to another color, simply replace the "#cccccc" with the RGB hex equivalent. If you need a cheat sheet, you might check out my Web Color Chart.

In many, though not all, browsers, you can also change the color of buttons and input elements through use of Cascading Style Sheet inline specifications. Let's do something weird: let's make the background for the search box yellow, with a small red border (again, using CSS), have the button bright green and the background of the text input box itself pink. (Note: no actual colors were harmed in the production of this example. Don't try this at home. Professional color mixer.):

Google

If you don't see all the colors, then be thankful that your browser isn't fully CSS compliant. Just this once. If you're in a really up-to-date browser like FireFox, though, you'll see the world's most colorful search box.

To accomplish the color changes, I changed the bgcolor attribute of the table tag and added three style= attributes to the appropriate HTML tags. Rather than duplicate all the code again, here are just the relevent few lines:

<table bgcolor="#ffff99" style="border:4px double #900">
...
<input type="text" name="q" size="40" maxlength="255"
  value="" style="background-color:#fcf;"></input>
<input type="submit" name="sa" value="Search"
  style="background-color:#6c3;"></input>

By the way, let me kvetch about one thing: Google, there is no </input> tag. The input tag doesn't have a paired closing tag and if you want to be producing proper XHTML you should be using <input .... /> instead.

Anyway, other than the frightening color scheme in this example, that should give you all the information you need to customize the Google search box for your own site!



Help others find this article at Del.icio.us, Digg, Netscape, Reddit, and Stumble Upon    

Subscribe!

Never miss another useful Q&A article again! Subscribe to AskDaveTaylor with Google Reader.

Comments

You can also change the color of the outline of the Google image like so.
grey
http://www.google.com/logos/Logo_25gry.gif
white
http://www.google.com/logos/Logo_25wht.gif
black
http://www.google.com/logos/Logo_25blk.gif

I haven't tried any other colors but you get the idea.

Posted by: Dave Taylor at February 8, 2005 11:02 PM

Just wondering if anyone ever got penalized by google for editing their "google code" even if its just the background color.

They mention this in their license agreement:
"Code Modification

Any AdSense ad code or search box code must be pasted directy into Web pages without modification. AdSense participants are not allowed to alter any portion of the ad code or change the layout, behaviour, or delivery of ads for any reason.
"

Posted by: Peter Cyr at June 6, 2005 6:20 PM

It's impressive how a company that uses the slogan of "do no evil" can have browbeaten and intimidated the online community, isn't it Peter? I would have to say that I have never heard of Google complaining about people sending them traffic, and if they were going to be upset about changing the background color of a form on MY web site, well, that's not the Google i know and like...

Posted by: Dave Taylor at June 6, 2005 8:14 PM

Does a search box, using the code as above, actually result in a search page with ads that make you money? You have an input element with forid=1, but I've found this to have no effect. You need FORID:1 in the "cof" input element (which also defines colours for the search results page). Without this, or with forid=0, you get a nicer search results page with the ads on the right instead of all across the top and bottom, BUT clicks don't seem to be credited through the adsense programme.

Posted by: Jonathan at April 27, 2006 4:04 PM

Well Dave, i am not agree with your answer to peter. As it is violating the license agreement, you can be banned anytime and the time u spent on doing this will be waste... It many the different questions that how much time google will take it to identifying it?

Well, not much if u directly modify the google adsense code. Another trick that u can use is use CSS for search. Using CSS u can modify the google seach without touch the adsense code, that what i am doing for the site i m building currently.

Posted by: John at May 24, 2007 3:25 AM

I did not do this because I did not want to be banned but my text on my blog is white and I need it to be black so I will be trying to figure that out. Maybe some CSS to look over.

Posted by: Ask Your PC at November 26, 2008 9:15 PM

I have a custom goole search engine on my site, on the results page they are displayed with a choice of colour backgrounds, can i make this background clear, or no background colour and see the page colour instead?? is this possible as i hate having a flat colour behind my results and it disturbs the natural flow of the website.

Many Thanks
George M Fasal

Posted by: George Fasal at December 3, 2008 3:06 AM

Hmmm...seems to me it would be better to make the style changes in your global CSS file. I'm sure this example was just to show it can be done, but for novices, learn to keep your CSS out of your HTML.

That being said, this is a nice post dealing with a popular question. Well done.

As for Google coming down on people for altering the look and feel of their search widget...no way! People at Google certainly have better things to do with their time.

Posted by: Evercleanse at December 9, 2008 9:59 AM

I have a lot to say, but ...
Starbucks coffee cup I have a lot to say, and questions of my own for that matter, but most of all I'd like to say thank you for all your efforts on this Web site by buying you a chai!

I do have a comment, now that you mention it!









Remember personal info?


Please note that I will never send you any unsolicited commercial email. Ever.

While I'm at it, please note that by submitting a question or comment you're agreeing to my terms of service, which are: you relinquish any subsequent rights of ownership to your material by submitting it on this site.









Uniblue: Free Virus Scan

Search
Find just the answers you seek from among our 2000+ free tech support articles by using our Lijit search engine.


Help!





Subscribe to
Ask Dave Taylor!

Add to Google Reader
Add to My Yahoo!
Subscribe in NewsGator Online

RDF   XML

Free Updates!
Sign up and get free weekly updates and special offers on books, seminars, workshops and more.


Recent Entries
Join the List!
Join my author info mailing list, where you'll learn about my upcoming books, speaking gigs, and more!


Book Links
© 2002 - 2009 by Dave Taylor. All Rights Reserved.

Note: This web site is for the purpose of disseminating information for educational purposes, free of charge, for the benefit of all visitors. We take great care to provide quality information. However, we do not guarantee, and accept no legal liability whatsoever arising from or connected to, the accuracy, reliability, currency or completeness of any material contained on this web site or on any linked site.

[whiteboard marker tray]
"Ask Dave Taylor®" is a registered trademark of Intuitive Systems, LLC.