Remove blank space and advertisement text on unfilled ad

Ads on my forum dont always fill and sometimes Google isn’t able to find an ad atm, so it just shows blank. This is fine, but I believe the advertisement text and the white space taken during this scenario should be removed since it leads to some confusion (eg. people thinking the above post was a promoted advertisemnt)

1 Like

I am not sure about the white-space but I think this works for the text:

1 Like

I guess that is a workaround for now, but the text is now always hidden. I would prefer to have it when an ad is showing, hidden when it’s not. I will mess with the css and see if I can make a selector that runs when ads are empty.

1 Like

I think it should be theoretically possible since google marks it with this property:

1 Like

I figured it out!!

It will keep the Advertisement text hidden by default, and only show it after confirming the ad is filled and displayed. This way I can ensure there is no confusion.

If you want to enable this on your forum, take a look at the detailed tutorial I posted on my blog

Edit: using revised version of working code after Firepup found a bug

Hope this helps someone!


Apparently google incorrectly fills out that field (Note the iframe):

1 Like

And apparently you can’t just check for the iframe either, as sometimes it adds a practically empty iframe.

I can’t cause this anymore, must have been a one-off.

No I tested it a lot, when its unfilled it still adds an iframe but keeps it empty. When its filled however the iframe is populated. It’s not a bug.

1 Like

There was at least once I manually un-hid the AD, and there was actually an AD there, even though it was marked as unfiled. I couldn’t cause it again after that though.

Just in case you wouldn’t be aware of it, the CSS :has selector isn’t widely supported, notably Firefox:


This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.