How to center align adsense responsive ads? here is the tutorial about how to align adsense ads script with responsive features. So as you know Google Adsense now has the latest features which Responsive ads, if you choose these type of ads for both text/image Responsive and Ad links Responsive, it will automatically show the ads which fit to the place as per the device screen size. So here we are giving some example how to align the Responsive ads to center.
If you are using exact ad unit size per screen width, that means if you modified the responsive ad code to show ads according to the screen size, for example Mobile, Tablet and Desktop then you need to use CSS media queries or modifying AdSense ad code. See the below example:-
Example Of Responsive Ad Code:-
<style>
.Inside_Post_1 { width: 320px; height: 100px; }
@media(min-width: 600px) { .Inside_Post_1 { width: 300px; height: 250px; } }
@media(min-width: 800px) { .Inside_Post_1 { width: 336px; height: 280px; } }
</style>
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Inside_Post_1 -->
<ins class="adsbygoogle Inside_Post_1"
style="display:inline-block"
data-ad-client="ca-pub-XXXXXXXXXXXXX"
data-ad-slot="XXXXXXX"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
This modified responsive ad code is very useful to show ads according to the screen size of the device, and it you are using this type ad code and unable align the ads to center then this topic will help you to solve the center align problem for the Adsense Responsive ads.
Positioning the ads on your site (Center Alignment)
You can change the position of the Google ads by using HTML tags i.e. <div> or <table> etc. and you are using these tags to change the position of images, paragraphs, etc. In the same you can use these tags to align Google Ads, if you want to show the ads in the center of your page then use the HTML tags <div align="center"> and </div>, your ads will appear in the center of your web page.
Example of Center Alignment Ad Code:-
<div align="center">
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Below Post Title -->
<ins class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-1234567890123456"
data-ad-slot="1234567890"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</div>
Example Of Center Alignment Responsive Ad Code:-
<style>
.Inside_Post_1 { width: 320px; height: 100px; }
@media(min-width: 600px) { .Inside_Post_1 { width: 300px; height: 250px; } }
@media(min-width: 800px) { .Inside_Post_1 { width: 336px; height: 280px; } }
</style>
<div align="center">
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Inside_Post_1 -->
<ins class="adsbygoogle Inside_Post_1"
style="display:inline-block"
data-ad-client="ca-pub-XXXXXXXXXXXXX"
data-ad-slot="XXXXXXX"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</div>
Use the above example to positioning your Google Adsense ads to center in the page, in this way you can put the ads in the center of the page. The above data-ad-client and data-ad-slot is for example purpose remember to change these according to your Adsense publication id and data-ad-slot.
How to Center Align Google Adsense |
If you are using exact ad unit size per screen width, that means if you modified the responsive ad code to show ads according to the screen size, for example Mobile, Tablet and Desktop then you need to use CSS media queries or modifying AdSense ad code. See the below example:-
Example Of Responsive Ad Code:-
<style>
.Inside_Post_1 { width: 320px; height: 100px; }
@media(min-width: 600px) { .Inside_Post_1 { width: 300px; height: 250px; } }
@media(min-width: 800px) { .Inside_Post_1 { width: 336px; height: 280px; } }
</style>
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Inside_Post_1 -->
<ins class="adsbygoogle Inside_Post_1"
style="display:inline-block"
data-ad-client="ca-pub-XXXXXXXXXXXXX"
data-ad-slot="XXXXXXX"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
This modified responsive ad code is very useful to show ads according to the screen size of the device, and it you are using this type ad code and unable align the ads to center then this topic will help you to solve the center align problem for the Adsense Responsive ads.
Positioning the ads on your site (Center Alignment)
You can change the position of the Google ads by using HTML tags i.e. <div> or <table> etc. and you are using these tags to change the position of images, paragraphs, etc. In the same you can use these tags to align Google Ads, if you want to show the ads in the center of your page then use the HTML tags <div align="center"> and </div>, your ads will appear in the center of your web page.
Example of Center Alignment Ad Code:-
<div align="center">
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Below Post Title -->
<ins class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-1234567890123456"
data-ad-slot="1234567890"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</div>
Example Of Center Alignment Responsive Ad Code:-
<style>
.Inside_Post_1 { width: 320px; height: 100px; }
@media(min-width: 600px) { .Inside_Post_1 { width: 300px; height: 250px; } }
@media(min-width: 800px) { .Inside_Post_1 { width: 336px; height: 280px; } }
</style>
<div align="center">
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Inside_Post_1 -->
<ins class="adsbygoogle Inside_Post_1"
style="display:inline-block"
data-ad-client="ca-pub-XXXXXXXXXXXXX"
data-ad-slot="XXXXXXX"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</div>
Use the above example to positioning your Google Adsense ads to center in the page, in this way you can put the ads in the center of the page. The above data-ad-client and data-ad-slot is for example purpose remember to change these according to your Adsense publication id and data-ad-slot.
Please Share Your Thoughts