示例工程 08-text-semantics
08-text-semantics/demo-01-emphasis/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; }
.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; }
p { margin: 0 0 10px; color: #334155; }
.note { color: #64748b; font-size: 13px; }
</style>
</head>
<body>
<h1>强调与语气</h1>
<div class="box">
<h2>strong:重要性</h2>
<p><strong>保存前先确认文件名。</strong>这是不能忽略的提醒。</p>
</div>
<div class="box">
<h2>em:语气重音</h2>
<p>我<em>不是</em>说不能用 div,而是说要先考虑语义。</p>
</div>
<div class="box">
<h2>嵌套</h2>
<p><strong>请<em>务必</em>先备份</strong>,再执行迁移。</p>
<p class="note">读屏会把 strong 读成重要性,把 em 读成重音;嵌套时两者都保留。</p>
</div>
<div class="box">
<h2>b 与 i:不带语义</h2>
<p><b>产品名</b>可以用 b,<i>拉丁学名</i>可以用 i,但它们不表示重要或强调。</p>
</div>
</body>
</html>