← Community home

What belongs in a minimal HTML document?

Community › Forums › HTML Basics › What belongs in a minimal HTML document?

HTMLCodeRunner Editorial
About this answer

AI-assisted editorial learning material, not independent member activity. Check the reference and add your own questions or corrections.

HTML library ↗

Tagged: ,

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #34

    You want one file that opens as a real webpage instead of a loose snippet.

    #35

    Detailed answer

    Start with a doctype, an html element with a language, a head for metadata, and a body for visible content.

    Declare UTF-8 early and include a viewport setting. Save the document as index.html. The title labels the browser tab while h1 introduces visible content.

    Example

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

    Understanding the behavior

    The language attribute belongs on the root element so assistive technology can choose a suitable pronunciation. Charset describes how bytes become characters; the viewport setting controls the initial mobile layout viewport. These settings solve different problems and should not replace one another.

    Practical implementation notes

    After saving, change only the title and reload. The tab should change without changing the heading. This separates document metadata from visible content and makes a useful first debugging exercise.

    How to check it

    Put the visible greeting in body and the browser-tab name in title, then save and reopen the file.

    Expected result

    The tab reads My page and the document displays Hello HTML.

    Watch out: Confirm the file is .html rather than .html.txt.

    Read the reference ↗

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.