示例工程 31-article-section-aside

31-article-section-aside/demo-01-article/index.html

html · 1.9 KB

运行:article 演示

点击「运行示例」后,左侧显示源码、右侧显示运行结果;console 输出会实时回传。

<!doctype html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>article 演示</title>
    <style>
      body { margin: 0; padding: 32px; background: #f8fafc; color: #0f172a; font-family: system-ui, sans-serif; line-height: 1.7; }
      .box { max-width: 720px; margin-bottom: 16px; padding: 18px; border: 1px solid #e2e8f0; border-radius: 12px; background: #fff; }
      h1 { margin: 0 0 16px; font-size: 28px; }
      h2 { margin: 0 0 8px; font-size: 17px; }
      h3 { margin: 0 0 6px; font-size: 16px; }
      p { margin: 0 0 10px; color: #334155; }
      article { padding: 14px; border: 1px solid #e2e8f0; border-radius: 10px; background: #f8fafc; }
      article + article { margin-top: 10px; }
      article header { padding-bottom: 8px; border-bottom: 1px solid #e2e8f0; }
      article footer { padding-top: 8px; color: #64748b; font-size: 13px; }
      code { padding: 1px 5px; border-radius: 4px; background: #f1f5f9; font-family: ui-monospace, monospace; }
    </style>
  </head>
  <body>
    <h1>article 演示</h1>

    <div class="box">
      <h2>文章 + 评论</h2>

      <article>
        <header>
          <h3>文章标题</h3>
          <p>2026-11-28 · 示例作者</p>
        </header>
        <p>article 可以独立分发,有 header 与 footer。</p>
        <footer>标签:语义</footer>
      </article>

      <article>
        <h3>评论一</h3>
        <p>评论也是独立内容,所以用 article。</p>
      </article>

      <article>
        <h3>评论二</h3>
        <p>嵌套 article 时,标题层级要跟着下降。</p>
      </article>
    </div>

    <div class="box">
      <h2>判断标准</h2>
      <p>把这块内容单独放到另一个页面,是否仍然完整成立?成立就用 article。</p>
      <p>如果只是同一主题下的一组段落,用 section。</p>
    </div>
  </body>
</html>