HTML: getting started
What HTML actually is, how a browser turns it into a page, and the smallest valid document you can write.
What HTML is (and is not)
HTML is a markup language: it describes the structure and meaning of content. It is not a programming language — there are no variables, loops, or conditions. Structure comes from HTML, presentation from CSS, behavior from JavaScript.
A browser reads your HTML and builds an in-memory tree called the DOM (Document Object Model). Everything you later do with JavaScript — changing text, reacting to clicks — is really an operation on that tree.
The smallest valid document
Every modern HTML document starts with <!DOCTYPE html>, which tells the browser to use standards mode rather than the old quirks mode. Include lang on the root element for screen readers and translation tools, and always set a character encoding.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>My first page</title>
</head>
<body>
<h1>Hello, world</h1>
<p>This is a paragraph.</p>
</body>
</html><head>holds machine-facing metadata: title, encoding, viewport, styles.<body>holds everything a human sees.- The viewport meta tag is what makes the page respond correctly on phones — without it mobile browsers pretend to be ~980px wide and zoom out.
Writing and viewing it
- Create a file named
index.html(the nameindexis special: servers serve it for a directory). - Paste the snippet above and save.
- Open it by double-clicking, or serve a folder with
python -m http.serverand visithttp://localhost:8000. - Right-click → Inspect to see the DOM the browser built.
file:// is fine for learning, but some features (fetch, modules, service workers) only work over http:// or https://. Use a local server when you get to those.FAQ
Do I need to memorize every tag?
Is HTML5 different from HTML?
Related
Elements and attributes Semantic layout
Last refreshed 2026-09-17.