示例工程 12-article-toc
12-article-toc/demo-02-article/index.html
点击「运行示例」后,左侧显示源码、右侧显示运行结果;console 输出会实时回传。
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>文章结构演示</title>
<style>
body { margin: 0; padding: 32px; background: #f8fafc; color: #0f172a; font-family: system-ui, sans-serif; line-height: 1.75; }
article { max-width: 760px; margin: 0 auto; padding: 24px; border: 1px solid #e2e8f0; border-radius: 12px; background: #fff; }
article > header { padding-bottom: 14px; border-bottom: 1px solid #e2e8f0; }
h1 { margin: 0 0 8px; font-size: 30px; }
h2 { margin: 24px 0 8px; font-size: 21px; }
h3 { margin: 16px 0 6px; font-size: 17px; }
p { margin: 0 0 10px; color: #334155; }
.meta { color: #64748b; font-size: 13px; }
nav ul { margin: 8px 0 0; padding-left: 20px; }
.footnotes { margin-top: 26px; padding-top: 14px; border-top: 1px solid #e2e8f0; color: #475569; font-size: 14px; }
a { color: #2563eb; }
</style>
</head>
<body>
<article>
<header>
<h1>文章结构演示</h1>
<p class="meta">2026-11-28 · 示例作者</p>
</header>
<nav aria-label="文章目录">
<ul>
<li><a href="#intro">引言</a></li>
<li><a href="#details">细节</a></li>
<li><a href="#notes">注释</a></li>
</ul>
</nav>
<section id="intro">
<h2>引言</h2>
<p>article 表示可独立分发的内容,header 放标题与元信息。</p>
</section>
<section id="details">
<h2>细节</h2>
<p>每个主题用 section 包住,配一个 h2。</p>
<h3>子主题</h3>
<p>子主题用 h3,层级不跳。</p>
</section>
<section id="notes">
<h2>注释</h2>
<p>注释列表放在文末,正文用链接指向。<a href="#fn1">[1]</a></p>
<ol class="footnotes">
<li id="fn1">这是示例注释,链接可以往返。</li>
</ol>
</section>
</article>
</body>
</html>