I'm using Google AdSense and I've read that they don't like people changing their Ad code.

I'm using this code:

 if ( adWidth <= 625 )
 google_ad_size = ["100", "50"];  /* Banner (468 x 60) */
 else if ( adWidth >= 626 )
 google_ad_size = ["100", "90"];

 document.write (
 '<ins class="adsbygoogle" style="display:inline-block;margin-top:45px;width:' 
  + google_ad_size[0] + '%;height:' 
  + google_ad_size[1] + 'px" data-ad-client="' 
  + google_ad_client + '" data-ad-slot="' 
  + google_ad_slot + '"></ins>'

I've added a margin-top and a width of 100%, now will Google punish me for doing that?

I don't want to end up a few weeks after launch with Google banning my account.

1 Answer 1


There are some guidelines by Google as to how you can add responsive ad units to your blog. See the following two pages from Adsense help center.

  1. About responsive ad units
  2. Create a responsive ad unit

According to information given on those pages, you should use CSS Media Queries and not Javascript to set the size of the ad unit based on the screen width.

I think that you are allowed to add a top margin to the code but to be on the safe side, follow this method - wrap the adsense code within another div and specify a margin for it. This page contains guidelines on what modifications are allowed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.