Note: This article relates to Google Ad Manager HTML ad tag code.
By default, when you add an ad unit to your website, it is left-aligned. To center your ad unit on the page, wrap your ad code in a <div>
that uses CSS Flexbox to center its contents.
<div style="display:flex;justify-content:center;">
<!-- AD CODE GOES HERE -->
</div>
Replace <!-- AD CODE GOES HERE -->
with your actual ad code.
Here is an example of how your final code might look:
<div style="display:flex;justify-content:center;">
<div id='div-gpt-ad-1602686592219-0' style='width: 300px; height: 250px;'>
<script>
googletag.cmd.push(function() { googletag.display('div-gpt-ad-1602686592219-0'); });
</script>
</div>
</div>
This will ensure your ad unit is centered on the page.