3

I just noticed that on sites with "auto ads" enabled, auto-placed AdSense units don't follow CSS rules regarding margin or padding in mobile view. They display across the entire viewport instead of allowing margin. The issue is not really applicable on desktop because ads rarely run border to border down to the pixel. But it does interfere with the design of mobile pages. See example below.

html{
    padding:15px;
}

body{
    margin:15px;
  }

https://i.imgur.com/7FdOyc8.png

As you can see, the ad is sticking out outside the allowable margin on the left and the right, unlike the element above it. All elements on the page obey these rules except Google's AdSense units. Again, these ads are in "auto" mode, which means you place one line of javascript in the <head> section of your HTML, and Google's algorithms choose the sizing and placement of the ad units.

Is there a way to force margins on these units?

  • could you provide the url of your website to see the issue? – Gabriel David Sep 3 at 4:29
  • I cannot see your ad – Gabriel David Sep 3 at 14:35
1

Auto ads are designed to ignore all your CSS and insert the ads in a consistent way across different sites. There is no way to control the position or margins of auto ads.

If you want more control of your ads, then you should disable auto ads and use traditional ad placements. See Ad placement and how to create it - AdSense Help for instructions on how to do so.

0

This happens because of Auto Ads inserted by Adsense, the script in the core of the website allows AdSense to place ads wherever they want. I think you should also contact your web host if they do provide live chat to find out if they allow parsing of code or not, because some web host block it due to malicious activity.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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