HTML element for ad?

耗尽温柔 提交于 2019-12-21 07:56:39

问题


Is there any authoritative information on the web concerning which HTML element to chose for an advertisement banner?

I considered <article> or <aside>, but I think more appropriate is simply: <div class="ad">


回答1:


In most cases I'd use the aside element:

The element can be used for […] for advertising, […] and for other content that is considered separate from the main content of the page.

As the aside element is a sectioning element, it creates an entry in the document outline, even if you don't use a heading explicitly. In most cases this would be what you want.


If you don't host the ad yourself, you might want to include it in iframe:

Here is an example of a page using an iframe to include advertising from an advertising broker:

<iframe src="http://ads.example.com/?customerid=923513721&amp;format=banner"
    width="468" height="60"></iframe>

(Where appropriate use the sandbox attribute for security.)


So, a simple blog post page could be structured like:

<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>

The page has the following outline:

  1. My blog
    1. My blog post
    2. Navigation
    3. Advertisement



回答2:


No, there is no HTML element defined to mean advertisement banner. In HTML5, <aside> means “tangentially related” content, which is quite different, and <article> is even more different. Whether you use <div class="ad"> or something else depends on what you expect to achieve. There is normally no reason to use any specific markup for ads.



来源:https://stackoverflow.com/questions/14384431/html-element-for-ad

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!