I am using responsive adsense ads. By default, the text ads are nicely left aligned but the image ads have a very wide left margin for some reason. I can't get rid of it, even if I take the most simple page, i.e. a page with only an ad on it:
<!DOCTYPE html>
<html>
<head>
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
</head>
<body>
<!-- Responsive Ad -->
<ins class="adsbygoogle"
style="display:block"
data-ad-client="xxx"
data-ad-slot="xxx"
data-ad-format="auto"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</body>
</html>
Textual ads are left aligned, e.g.:
but image ads contain some wide left margin, e.g.:
My question is how can I make sure that image ads are left-aligned?
Try putting it in a container and give the container a max-width
and maybe text-align: left
.
<!DOCTYPE html>
<html>
<head>
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
</head>
<body>
<!-- Responsive Ad -->
<div id="ad" style="width: 100%; max-width: 600px; text-align: left;">
<ins class="adsbygoogle"
style="display:block"
data-ad-client="xxx"
data-ad-slot="xxx"
data-ad-format="auto"></ins>
</div>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</body>
</html>
Hard to solve without having a test page that you can try playing with.
Try this - put your adsense code in a div, and style the div like this:
<div style="margin: 5px !important; float: left !important;">
--Put your AdSense ad code here --
</div>
I have seen your webpage. And I have applied the following style
Try the following css in your file
.container {
padding-left:0px;
margin-left:10px;
}
Let me know if it is helpful
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With