QUORA

Thursday, 30 July 2026

Auto ads Code

 Skip to main content

Help Center

Community

Announcements

Code implementation guide

Where to place ad unit code in your HTML

Next: Connect to AdSense and show ads on your WordPress site

This article describes where to add ad unit code in your HTML to serve AdSense ads.


If you are not familiar with working with HTML, you should first see the instructions on how to paste ad code in your HTML pages, depending on the tools that you use. Before proceeding, you should also know the differences between AdSense code and ad unit code.


Tip: For help with HTML, try searching for online resources using terms like "HTML basics"

On this page

Where to add ad unit code

How to position ads on your site with HTML

Where to add ad unit code

After you get and copy your ad unit code, you need to paste it between the <body> and </body> tags of your page. If you paste the ad code outside the <body> tags it will prevent your ads from appearing correctly.


Note: This is sample code only which shows where to add ad unit code. Don't use this code exactly in your own site's code.

Example of an HTML page before ad unit code has been added

<html>


   <head>


      This is the head of your page.


      <title>Example HTML page</title>


   </head>


   <body>


      This is the body of your page.


   </body>


</html>


Example of an HTML page after ad unit code has been added in the <body> tag

<html>


   <head>


      This is the head of your page.


      <title>Example HTML page</title>


   </head>


   <body>


      This is the body of your page.


      <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-1234567890123456" crossorigin="anonymous"></script>

<!-- Homepage Leaderboard -->

<ins class="adsbygoogle"

style="display:inline-block;width:728px;height:90px"

data-ad-client="ca-pub-1234567890123456"

data-ad-slot="1234567890"></ins>

<script>

(adsbygoogle = window.adsbygoogle || []).push({});

</script>


   </body>


   </html>


How to position ads on your site with HTML

Just like the other elements of your site (images, paragraphs, etc.), you can change the position of your Google ads by using HTML tags (<div>, <table>, etc.). For example, if you surround your ad code with the HTML tags <div align="center"> and </div>, your ads will appear in the center of your page.


Example of an HTML <div> element used to position an ad in the <body> tag

<html>


   <head>


      This is the head of your page.


      <title>Example HTML page</title>


   </head>


   <body>


      This is the body of your page.


      <div align="center">


      <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-1234567890123456" crossorigin="anonymous"></script>

<!-- Homepage Leaderboard -->

<ins class="adsbygoogle"

style="display:inline-block;width:728px;height:90px"

data-ad-client="ca-pub-1234567890123456"

data-ad-slot="1234567890"></ins>

<script>

(adsbygoogle = window.adsbygoogle || []).push({});

</script>


      </div>


   </body>


   </html>



Give feedback about this article

Next: Connect to AdSense and show ads on your WordPress site

Was this helpful?

YesNo

Need more help?

Try these next steps:

Post to the help community

Get answers from community members

Contact us

Tell us more and we’ll help you get there

Code implementation guide

About the AdSense code

Get and copy the AdSense code

How to paste the ad code in your page

Where to place AdSense code in your HTML

Where to place ad unit code in your HTML

WordPress sites

Common issues with ad code implementation

Use Chrome DevTools to troubleshoot issues with your ads not showing

Integrate the AdSense ad code with a Content Security Policy (CSP)


Unlock your revenue with personalized tips today!

Visit the 

Optimization tips for AdSense page to see personalized suggestions to maximize your revenue.


Unlock now


Language


Help guide

No comments:

Post a Comment

https://goniks.blogspot.com/

Leaderboard

    <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-1234567890123456" crossorig...

https://goniks.blogspot.com/