广告的HTML元素?

fek*_*lee 10 html html5 ads naming-conventions semantic-markup

网上是否有关于为广告横幅选择哪个HTML元素的权威信息?

我考虑过<article>或者<aside>,但我认为更合适的是:<div class="ad">

uno*_*nor 8

在大多数情况下,我会使用aside元素:

该元素可用于广告,[...]以及被认为与页面主要内容分开的其他内容.

由于aside元素是分区元素,因此即使您未明确使用标题,它也会在文档大纲中创建条目.在大多数情况下,这将是你想要的.


如果您没有自己托管广告,可能需要将其包含在iframe:

下面是使用一个页面的例子iframe包括广告,从广告经纪人:

<iframe src="http://ads.example.com/?customerid=923513721&amp;format=banner"
    width="468" height="60"></iframe>
Run Code Online (Sandbox Code Playgroud)

(在适当的地方使用该sandbox属性进行安全性.)


因此,一个简单的博客帖子页面可以构造如下:

<body>

  <h1>My blog</h1>

  <article>
    <h1>My blog post</h1>
    <p>…</p>
  </article>

  <nav>
    <h1>Navigation</h1>
    <!-- site-wide navigation -->
  </nav>

  <aside>
    <h1>Advertisement</h1> <!-- or omit the heading altogether, it doesn't change the outline -->
    <iframe></iframe>
    <footer><small>Advertisement by ACME Inc.</small> <!-- or whatever --> </footer>
  </aside>

</body>
Run Code Online (Sandbox Code Playgroud)

该页面包含以下大纲:

  1. 我的博客
    1. 我的博文
    2. 导航
    3. 广告