示例工程 02-document-structure

02-document-structure/demo-02-head-body/index.html

html · 1.4 KB

运行:head 与 body

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

<!doctype html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>head 与 body</title>
    <meta name="description" content="演示 head 不显示,body 显示。" />
    <style>
      body { margin: 0; padding: 32px; background: #f8fafc; color: #0f172a; font-family: system-ui, sans-serif; line-height: 1.75; }
      h1 { margin: 0 0 8px; font-size: 30px; }
      .box { max-width: 680px; padding: 18px; border: 1px solid #e2e8f0; border-radius: 12px; background: #fff; }
      .tag { color: #2563eb; font-size: 10px; font-family: ui-monospace, monospace; letter-spacing: 0.08em; }
      h2 { margin: 4px 0 8px; font-size: 18px; }
      p, li { color: #334155; font-size: 14px; }
      code { padding: 1px 5px; background: #f1f5f9; border-radius: 4px; font-family: ui-monospace, monospace; }
    </style>
  </head>
  <body>
    <div class="box">
      <span class="tag">BODY</span>
      <h1>你看到的内容都在 body</h1>
      <p>标题、段落、列表、链接都属于 body。</p>
      <h2>head 在哪里?</h2>
      <ul>
        <li><code>title</code> 显示在标签页,不显示在页面里</li>
        <li><code>meta charset</code> 告诉浏览器编码</li>
        <li><code>meta viewport</code> 控制移动端视口</li>
      </ul>
    </div>
  </body>
</html>