To display Google Ads in different sizes for mobile and desktop devices, you can use responsive ad units. Responsive ad units are designed to automatically adjust the ad size and format based on the size and type of device used to view the web page.
Here’s how you can create a responsive ad unit that can display different sizes for mobile and desktop devices:
- Log in to your Google AdSense account and navigate to the “Ads” tab.
- Click the “+New ad unit” button.
- Select “Display ads” as the ad type and choose the ad size that you want to use for desktop devices. For example, you can select the 300×250 ad size.
- Check the box that says “Automatically adjust the ad size to fit the user’s screen” to make the ad unit responsive.
- Under “Ad type”, choose “Text & display ads”.
- Click “Create” to generate the responsive ad unit.
Google AdSense will now automatically adjust the ad size and format based on the size and type of device used to view the web page. This means that your responsive ad unit will display a 300×250 ad size for desktop devices and a smaller ad size for mobile devices.
Code for displaying 30×250 size Google Ads
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <!-- Your responsive ad unit ID --> <ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-1234567890123456" data-ad-slot="1234567890" data-ad-format="auto"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script>
HTML and CSS code for basic Keyword Research Tool
Email Signup Form Code for Website
In this example, the ‘data-ad-format’ attribute is set to “auto”, which allows Google AdSense to automatically adjust the ad size and format based on the device used to view the web page.
Note that you need to replace the ‘data-ad-client’ and ‘data-ad-slot’ values with your unique AdSense ID and ad slot respectively. You can also customize the style attribute to change the look and feel of the ad unit as needed.