取得並複製廣告單元代碼後,您必須將其貼到網頁的 <body>
和 </body>
代碼之間。如果您將廣告程式碼貼到 <body>
代碼之外,廣告就無法正常顯示。
提示:如需 HTML 相關說明,請使用「HTML 基本概念」等字詞搜尋線上資源
未加入廣告單元程式碼的 HTML 網頁範例
<html>
<head>
這部分為頁首。
<title>HTML 範例網頁</title>
</head>
<body>
這部分為網頁內文。
</body>
</html>
<head>
這部分為頁首。
<title>HTML 範例網頁</title>
</head>
<body>
這部分為網頁內文。
</body>
</html>
已在內文中安插廣告單元程式碼的 HTML 網頁範例
<html>
<head>
這部分為頁首。
<title>HTML 範例網頁</title>
</head>
<body>
這部分為網頁內文。
<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>
<head>
這部分為頁首。
<title>HTML 範例網頁</title>
</head>
<body>
這部分為網頁內文。
<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>
注意:以上程式碼僅供參考,請勿加進您網站的 HTML 碼中。
使用 HTML 決定廣告在網站上的刊登位置
您可以使用 HTML 標記 (<div>
、<table>
等) 更改 Google 廣告的位置,就像安排網站上其他元素 (圖片、文章等) 一樣。舉例來說,如果您使用 <div align="center">
和 </div>
這兩個 HTML 標記包圍住廣告程式碼,廣告會顯示在網頁中央。
<html>
<head>
這部分為頁首。
<title>HTML 範例網頁</title>
</head>
<body>
這部分為網頁內文。
<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>
<head>
這部分為頁首。
<title>HTML 範例網頁</title>
</head>
<body>
這部分為網頁內文。
<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>
注意:以上程式碼僅供參考,請勿加進您網站的 HTML 碼中。