1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

AdSense units don't respect CSS margin rules

Discussion in 'AdSense' started by Knocks, Sep 2, 2019.

  1. #1
    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;
          }
    Code (markup):
    [​IMG]

    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.
    SEMrush
    Is there a way to force margins on these units?
     
    Knocks, Sep 2, 2019 IP
    SEMrush