示例工程 01-what-is-html

01-what-is-html/app/index.html

html · 3.2 KB

运行:我的第一页 · HTML 入门

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

<!doctype html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>我的第一页 · HTML 入门</title>
    <style>
      * { box-sizing: border-box; }
      body {
        margin: 0;
        min-height: 100vh;
        padding: 32px 20px;
        background: #f8fafc;
        color: #0f172a;
        font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
        line-height: 1.75;
      }
      .page { width: min(100%, 720px); margin: 0 auto; }
      .site-header {
        display: flex;
        justify-content: space-between;
        gap: 16px;
        padding-bottom: 14px;
        border-bottom: 1px solid #e2e8f0;
      }
      .brand { font-weight: 700; letter-spacing: 0.14em; font-size: 13px; }
      nav a { color: #2563eb; font-size: 13px; text-decoration: none; }
      nav a + a { margin-left: 14px; }
      main { padding: 32px 0; }
      .eyebrow { color: #64748b; font-size: 11px; letter-spacing: 0.18em; }
      h1 { margin: 6px 0 12px; font-size: clamp(32px, 6vw, 48px); line-height: 1.1; }
      .lead { margin: 0 0 20px; color: #334155; font-size: 17px; }
      section { margin-top: 28px; padding: 20px; border: 1px solid #e2e8f0; border-radius: 14px; background: #fff; }
      h2 { margin: 0 0 10px; font-size: 20px; }
      p { margin: 0 0 10px; color: #334155; }
      code { padding: 1px 5px; border-radius: 4px; background: #f1f5f9; font-family: ui-monospace, Menlo, monospace; font-size: 0.92em; }
      ul { margin: 8px 0 0; padding-left: 22px; color: #334155; }
      li + li { margin-top: 4px; }
      footer { padding-top: 18px; border-top: 1px solid #e2e8f0; color: #64748b; font-size: 12px; }
      @media (max-width: 520px) {
        .site-header { flex-direction: column; }
        section { padding: 16px; }
      }
    </style>
  </head>
  <body>
    <div class="page">
      <header class="site-header">
        <span class="brand">HTML NOTES</span>
        <nav aria-label="页面导航">
          <a href="#tags">标签</a>
          <a href="#structure">结构</a>
        </nav>
      </header>

      <main>
        <p class="eyebrow">LESSON / 01</p>
        <h1>我的第一页</h1>
        <p class="lead">
          这是一个只用 HTML 结构组织起来的页面。标题、段落、列表与链接
          各司其职,浏览器负责把它们显示出来。
        </p>

        <section id="tags">
          <h2>标签、元素与属性</h2>
          <p>
            <code>&lt;h1&gt;我的第一页&lt;/h1&gt;</code> 是一个元素:
            开始标签、内容、结束标签。属性写在开始标签里,例如
            <code>href="/docs"</code>。
          </p>
        </section>

        <section id="structure">
          <h2>页面需要结构</h2>
          <ul>
            <li><code>&lt;header&gt;</code> 放品牌与导航</li>
            <li><code>&lt;main&gt;</code> 放本页主要内容</li>
            <li><code>&lt;footer&gt;</code> 放版权与说明</li>
          </ul>
        </section>
      </main>

      <footer>
        <p>示例数据,仅用于教程演示。</p>
      </footer>
    </div>
  </body>
</html>