HTML Code Generator

Generate a valid HTML5 starting file with the head tags and body structure already in place.

HTMLsemantic skeleton
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <meta name="description" content="Long term notes on a 1.2 litre titanium camping kettle.">
  <title>Trail Kettle Field Notes</title>
  <link rel="stylesheet" href="styles.css">
</head>
<body>
  <header>
    <nav aria-label="Main">
      <a href="/">Home</a>
      <a href="/about">About</a>
    </nav>
  </header>
  <main>
    <h1>Trail Kettle Field Notes</h1>
    <p>Replace this paragraph with your content.</p>
  </main>
  <footer>
    <p>&copy; 2026 Example</p>
  </footer>
  <script src="app.js" defer></script>
</body>
</html>
Runs locally in your browser

About the HTML Code Generator

Starting a page from nothing means retyping the same six lines of head markup and hoping none of them is missing. This generator writes them for you: the HTML5 doctype, a lang attribute on the root element, the UTF-8 charset declaration, the viewport meta that stops phones rendering the page at desktop width, a meta description and a stylesheet link.

Order matters more than it looks. The charset declaration must appear in the first 1024 bytes of the document, which is why it comes first here; put it after a long block of meta tags and a browser may guess the encoding and mangle every accented character on the page. The lang attribute feeds screen reader pronunciation and browser translation prompts, so set it to the language you are actually writing in. The script tag is emitted with defer, so it downloads in parallel and runs after the document is parsed, which is almost always what you want.

Three body shapes are available. The semantic one gives you header, nav, main and footer, which is a sound default for a content page. The article shape is aimed at a blog post and includes a <time> element with a machine readable date. The minimal one is a heading and a paragraph for a scratch file. Once the page has real content, the HTML Validator checks it and the HTML Formatter tidies the indentation.

How to use

  1. Enter the page title, description and language.
  2. Choose the body structure you want to start from.
  3. Set the stylesheet and script paths, or clear them to omit the tags.
  4. Copy the file, or download it as index.html.

Common questions

Why must the charset come first?
Browsers only look for it in the first 1024 bytes. Later than that and the encoding is guessed, which garbles accented and non-Latin characters.
What does the viewport meta actually do?
It tells mobile browsers to use the device width instead of a simulated 980 pixel desktop, which is what makes responsive CSS take effect.
Why is defer on the script tag?
It lets the script download while parsing continues and run once the DOM is ready, so you avoid both blocking and a missing element error.
Can I drop the stylesheet or script link?
Yes. Clear the field and that tag is left out of the generated file.