学习库HTMLDocument Structure

Document Structure

Build the complete shell every standards-friendly HTML page needs.

更新于 适用于 HTML Living Standard

A complete page includes metadata for the browser and a body for visible content. This predictable shell helps browsers, search engines, and accessibility tools interpret the document correctly.

The page skeleton

index.html
<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>My learning journal</title>
  </head>
  <body>
    <h1>My learning journal</h1>
  </body>
</html>

The doctype selects standards mode. lang identifies the document language. UTF-8 supports modern text, and the viewport declaration lets mobile browsers use the device width.

Head and body

The head contains information about the page: its title, description, icons, styles, and other metadata. The body contains everything rendered as page content.

index.html
<head>
  <title>Journal · Ada</title>
  <meta name="description" content="Notes from Ada's web-learning journey." />
</head>

Nest cleanly

Elements must be nested, not crossed. Indentation is optional to the browser but essential for readers.

clean-nesting.html
<main>
  <article>
    <h1>A clear document</h1>
    <p>Each child closes before its parent.</p>
  </article>
</main>

Keep this

Use one document shell per page, declare its language, keep metadata in head, and place visible content in body.

学习位置已保存在此设备上。