Adsense responsive ads ignore or override css styles

I had some trouble getting adsense responsive ads to respond to css styling. I thought it might be helpful to share my experience because I could not find anyone else with the same problem. I tried to follow the instructions here but I found the ads would still exceed the height I configured. My code looked something like this:

The script and html was taken from my adsense account and I only added the responsive_ad class to the ins. If you look closely you will notice two subtle differences between my html and the example given by adsense. data-full-width-responsive="true" and data-ad-format="auto" were only present in my version. I expected data-full-width-responsive to override the width but it appears to override the height as well. ad-format is only needed if you aren't providing your own sizes. Removing these two attribute makes it work as expected. The ads now honour the css height and width.

References:

Comments

Popular Posts