Forum Moderators: martinibuster

Message Too Old, No Replies

Responsive ad question on how to modify the code

         

virtualreality

3:43 am on Jun 8, 2016 (gmt 0)

10+ Year Member Top Contributors Of The Month



I am using one responsive ad for my top banner. I want to disable it for small screens and have it only on desktop. I modified the code according to Google Guidelines and this is what I came up with. Could you please help proofreading it and let me know if this is correct?


<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<style>
.adslot_1 { display:block; }
@media (max-width: 799px) { .adslot_1 { display: none; } }
</style>
<ins class="adsbygoogle adslot_1"
style="display:block"
data-ad-client="xxx"
data-ad-slot="xxx"
data-ad-format="horizontal"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>

Rasputin

4:53 am on Jun 8, 2016 (gmt 0)

10+ Year Member



You should use the code at [support.google.com...]
Eg they use display:inline-block in the style and no style decared in the <ins> section
Note also 800 px will include some tablets , ipad horizontal is about 1024px

IanTurner

6:34 am on Jun 8, 2016 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



I don't think you can display:none Adsense ads and remain within Adsense Terms of service. You would need to use a server side script of some kind.

virtualreality

6:39 am on Jun 8, 2016 (gmt 0)

10+ Year Member Top Contributors Of The Month



According to [support.google.com...] you can use display: none. Scroll down to "Hiding ads for specific screen sizes example"

virtualreality

5:16 pm on Jun 8, 2016 (gmt 0)

10+ Year Member Top Contributors Of The Month



Thank you Rasputin. This info was very helpful.