我应该把元素ouide放在主要元素的内部吗?

Pra*_*hta 11 seo html5 accessibility semantic-markup

假设aside元素包括"哦,顺便说一下......"等内容,例如阅读建议,广告或交叉销售.

  1. 在aside外面是否在语义上可以main吗?
  2. 如果是的话,如果我aside不在外面,它是否优于可访问性main,例如"跳到主要内容"命令?
  3. 最后但并非最不重要,我想知道如果我aside在外面或内部包含标签,是否有任何SEO影响main.

uno*_*nor 17

在HTML5中,它仅定义aside为"与aside元素周围的内容相关".

在HTML 5.1(CR)中,定义变得更加具体,因为它现在说aside"与父母分区内容的内容相关 ".

在更新的定义之后,aside元素应该在与其相关的section元素的内部.的main元件是不一个切片元件(相似的元件article,section,body,figure等是).当然,你可以仍然放置aside在main,但它会涉及到最近的切片元素的父main.

这意味着aside在这两个例子中没有语义差异(for ):

<body>
  <main></main>
  <aside><!-- related to the body --></aside>
</body>
Run Code Online (Sandbox Code Playgroud)
<body>
  <main><aside><!-- related to the body --></aside></main>
</body>
Run Code Online (Sandbox Code Playgroud)

显示几个不同情况的示例:

<body>

  <main>

    <article>

      <aside><!-- related to the article --></aside>

      <section>

        <aside><!-- related to the section --></aside>

        <blockquote>
          <aside><!-- related to the blockquote (not to the section!) --></aside>
        </blockquote>

        <div>
          <aside><!-- related to the section (not to the div!) --></aside>
        </div>

      </section>

    </article>

    <aside><!-- related to the body (not to the main!) --></aside>

  </main>

  <aside>
    <!-- related to the body -->
    <aside><!-- related to the (parent) aside --></aside>
  </aside>

  <nav>
    <aside><!-- related to the nav --></aside>
  </nav>

  <footer>
    <aside><!-- related to the body (not to the footer!) --></aside>
  </footer>

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


aar*_*ian 9

如果你<aside>的内容与你的内容直接相关,<main>那么我会把它留在<main>.现在,据说......

  1. 是的,在语言上可以<aside>在外面使用<main>(例如,它是有效的,但你的内容可能另有保证).
  2. 我不明白你是怎么想跳过链接进场这里,但在其他方面<aside>之外<main>有没有危害,也不利于可访问性.只要你遵循良好的结构和有效的加价,你应该没事.
  3. 我不知道.我在我的网站<aside>外面<main>,也有<aside>内部<main>,我看到我的排名没有差别.鉴于搜索引擎通常对这样的特定位不透明,如果您担心,我会考虑进行一些A/B测试.

来自HTML5 Doctor的相关资料,由HTML5规范编辑之一编写: