示例工程 07-headings-paragraphs

07-headings-paragraphs/demo-02-paragraphs/index.html

html · 1.7 KB

运行:段落演示

点击「运行示例」后,左侧显示源码、右侧显示运行结果;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; }
      .box { max-width: 720px; margin-bottom: 18px; 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; }
      p { margin: 0 0 12px; color: #334155; }
      address { padding: 10px 12px; border-left: 3px solid #2563eb; background: #eff6ff; color: #1e3a8a; font-style: normal; }
      pre { margin: 0; padding: 10px; overflow-x: auto; border-radius: 8px; background: #0f172a; color: #e2e8f0; font-size: 12px; }
    </style>
  </head>
  <body>
    <h1>段落演示</h1>

    <div class="box">
      <h2>正确:一段一个意思</h2>
      <p>第一段说明背景:为什么要拆分段落。</p>
      <p>第二段说明做法:一段只讲一件事。</p>
      <p>第三段说明结果:读者更容易扫读。</p>
    </div>

    <div class="box">
      <h2>正确:br 只用于地址换行</h2>
      <address>
        上海市徐汇区<br />
        示例路 88 号<br />
        邮编 200000
      </address>
    </div>

    <div class="box">
      <h2>错误写法(仅展示源码)</h2>
      <pre>&lt;p&gt;第一段&lt;br&gt;&lt;br&gt;第二段&lt;br&gt;&lt;br&gt;第三段&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;</pre>
      <p>连续 br 不会产生段落语义,空段落也不该用来撑间距。</p>
    </div>
  </body>
</html>