Centre an Adsense Unit



You have your nice adsense unit but you want to center or you want to give it a nice background.

Really simply fix but ill document it either way.

To centre the adsense unit you can use a div or a table, div is better but ill do both.

Centre Adsense with a div

Copy the code below replacing the adsense code with your own

<div align="center"><script type="text/javascript"><!--
google_ad_client = "ca-pub-121212121212121212";
/* Menu  */
google_ad_slot = "12121212121212";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>

That will centre the adsense unit in the area you put it as seen here..

centre adsense ad

centre adsense ad code

 

Centre With A Table

 

If you want to change the color behind the until you can use a table to do so. See the code below and replace your adsense code.

<table width=”966″ border=”0″>
<tr>
<th bgcolor=”#cccccc” scope=”row”><script type=”text/javascript”><!–
google_ad_client = “ca-pub-121212121212121212”;
/* Menu  */
google_ad_slot = “121212121212”;
google_ad_width = 728;
google_ad_height = 90;
//–>
</script>
<script type=”text/javascript”
src=”http://pagead2.googlesyndication.com/pagead/show_ads.js”>
</script></th>
</tr>
</table>
As seen here…

centre adsense

centre adsense

Set the table width to be the size you want and you will see I use the colour of #cccccc , to find your colour use this app… http://www.colorpicker.com/ and copy your code.

 

Job done, simple!


Tags: adsense

Allen White

Allen is a Consultant for ITPS in the North East of England and holds the following accreditations. MCSA, MCSE, MCTS, MCITP, CCA, CCSP, VCP 4,5 and HP ASE, AIS - Network Infrastructure.

Leave a comment

Categories

Vote!

What Web Browser Do You Use?

View Results

Loading ... Loading ...

Vote!

What do you prefer..VMware or Hyper-V?

View Results

Loading ... Loading ...