1

My educational site is in Azerbaijani language and I use Google AdSense Auto Ads. But mostly Google can not find appropriate ads for my site and shows an empty space, squared gaps inside of my articles.

How to prevent it with CSS. I disabled auto ads by hiding inside of some containers. But this method hides Auto Ads at all. I need to hide only an empty block, when Ads are not translating but block appears.

So I hide Auto ads from the top of my pages with the following CSS rule:

body > .google-auto-placed{
    visibility: hidden;
    display: none;
}

As you see, there is an empty rectangle instead of ads after the "Search box". I want to hide it, when no ads are broadcasting

As you see, there is an empty rectangle instead of ads after the "Search box"

Jeff_Alieffson
  • 2,248
  • 25
  • 29
  • Can you elaborate more about what do you mean by "But this method hides Auto Ads at all."? And what you would like to do with some image example if possible. – Mukyuu Apr 02 '19 at 03:14
  • My code example prevents Auto ads showing directly inside of .as direct child. It's OK for me. Because this way I can prevent ads showing outside of my main container. My question is about showing a blank space. I want to prevent Google Ads showing an empty rectangle, when no ads inside. Look at attached image – Jeff_Alieffson Apr 02 '19 at 03:26
  • I can't say much since I don't know the exact markup. But possibly change your ["If no ads available"](https://support.google.com/adsense/answer/113262?hl=en) option into *Collapse the ad unit, otherwise show color* and check the markup for the color then hide them. – Mukyuu Apr 02 '19 at 03:50
  • It is like Parent selector problem. https://stackoverflow.com/questions/1014861/is-there-a-css-parent-selector Because auto ads has not an option "If no ads available", like other ad Units, I can only check existence of some classes or elements inside of ads container. In this case I'll have the parent selector problem. If I can select the parent of inexisting child, I can hide it. – Jeff_Alieffson Apr 02 '19 at 05:15
  • 1
    I see, if you really need to select the parent then you can use jQuery like in this [answer](https://stackoverflow.com/a/1901332/3654837). Since at the moment there is no CSS parent selector. – Mukyuu Apr 02 '19 at 06:26
  • Thank you. I saw it. But I must run the similar JS code, after all AdSense Auto Ad units has been loaded. – Jeff_Alieffson Apr 02 '19 at 18:49

0 Answers0