How to center Google AdSense ads
It took me awhile to figure out how to center Google AdSense ads. Searches showed that many other people were running into the same issue, so I thought I would share my method for centering.
At first I tried things like margin:auto, center and padding in a <div> wrapped around the ad, but nothing seemed to work. The reason for this is the AdSense box is absolutely positioned. The easy fix for this is to create a CSS class or inline style as shown below.
CSS class
.adSenseCenter {
position:relative;
width:120px;
margin:auto;
}
Container <div>
<div class="adSenseCenter"> adSense code goes here </div>
Or quick and dirty inlines style.
<div style="position:relative; width:120px; margin:auto;"> adSense code goes here </div>
Don’t forget that the width of the <div> must equal the width of the adSense ad. Now you can center your ads.








Keith December 11, 2009 at 9:36 am
I realize this post is over a year old, but THANK YOU so much for posting it. I’ve been trying to center my adsense header for quite some time and just become more frustrated and more frustrated. You advice worked perfectly!
chris March 21, 2010 at 11:52 pm
works a charm, but would possible to move the ad down a little.
eg: in the center and also moved down a little?
my google ad is againest the very top and i would like to move it down a bit still centered.
thanks.
Ian Hoar | Follow me on Twitter | March 22, 2010 at 12:07 am
Chris you can probably position it relatively or use a margin. Something like margin:20px auto 0 auto;
Matt October 12, 2010 at 4:23 am
Thanks very much for this. First search hit in Google and centred my ads correctly. Used in conjunction with advert manager plugin for wordpress.
Antonio November 1, 2010 at 7:18 pm
Great!!!! Thanks a lot Ian, after almost 2 hours Googling and trying many many different ways of centering and moving my adsense with no positive results, I found your site and man it just made my day after so much frustration.
Greetings form México
Simon | Follow me on Twitter | September 21, 2011 at 1:13 pm
Thank you Ian, because of you and you only did I manage to center my adsense
Enjoy your day.
Greetings from South Africa
DateSphere - Chris October 18, 2011 at 4:04 pm
Thanks so much for posting this, just implemented on my site and it worked great!
Tall Curly Biscuit October 24, 2011 at 9:29 pm
Thank you! Nothing ever works the first time, except this!
Joseph November 22, 2011 at 12:26 pm
This worked like a charm! On both FF7 and IE7. Thank you!
Mario February 5, 2012 at 7:45 am
This worked perfectly!! Thank you very much!!
Best regards