【问题标题】:The right way to use <section> and <article> for SEO使用 <section> 和 <article> 进行 SEO 的正确方法
【发布时间】:2021-11-12 06:29:01
【问题描述】:

如果我拼错了,请原谅我并纠正它。

我不确切知道如何使用这两个元素 (Article | Section) 现在我想启动一个具有完全标准 HTML 代码的网站, 现在,您认为我网站上的文章应该如何结构化?我在哪里可以更好地放置网站标题? 我被这两个选项卡住了。

<!-- 1 -->
<section>
    <header>
        <h1>title of page</h1>
    </header>
    <article>
        <p>some text</p>
    </article>
</section>

<!-- 2 -->
<section>
    <article>
        <header>
            <h1>title of page</h1>
        </header>
    </article>
    <p>some text</p>
</section>

如果两者都不正确,你有什么建议?

我的英语很差。所以我不能再用任何问题了。但我理解编码。请通过写代码和简单的句子向我解释,不要说你的问题有答案。

【问题讨论】:

    标签: html seo


    【解决方案1】:

    详细了解 Mozilla 的 HTML element article

    HTML 元素代表一个自包含的组合 文档、页面、应用程序或站点,旨在 可独立分发或可重复使用(例如,在联合中)……每个 post 将包含在一个元素中,可能带有一个或 内有更多。

    article 元素不同,section element

    HTML 元素代表一个通用的独立部分 一个文档,没有更具体的语义元素 代表它。

    因此,article 元素可以包含 section 元素。但section 元素不能包含任何其他语义元素。

    因此,您的示例可以这样呈现:

    <header>
     <h1>The article News from Valinor of Gandalf</h1>
    </header>
    <article>
      <h2>News from Valinor</h2>
      <p>A short introduction to the content of the article.</p>
      <section>
        <h3>The name of section</h3>
        <p>The content of section.</p>
      </section>
      <section>
        <h3>The name of section</h3>
        <p>The content of section.</p>
      </section>
      ...
    </article>
    <footer>
     <h2>Publisher and copyright holder</h2>
     <p>Publisher and © 2021 Gandalf</p>
    </footer>

    【讨论】:

      猜你喜欢
      • 2012-02-02
      • 2022-11-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-01-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多