Web markup · Beginner to advanced

Learn HTML step by step

Build a web page from the beginning, then learn headings, links, images, forms, accessibility and page metadata using clear HTML examples. Every module explains the idea in plain language, walks through a code example and gives you a small task to try yourself.

Version snapshot: HTML Living Standard. HTML is maintained as a continuously updated Living Standard, not as numbered HTML 5.x releases. This guide follows the WHATWG standard checked on 21 October 2026.

Before you begin

No coding experience required. A text editor and modern browser are enough to create and inspect your first HTML file.

What you’ll be able to do

Write semantic, accessible documents and connect their structure cleanly to CSS and JavaScript.

Work through the modules in order if you’re new to HTML. If you already know the basics, use the contents list to jump to a topic. Try each example by changing one value, running it again and explaining the result in your own words.

HTML terms in simple language

Element
A piece of page structure, usually written with a start tag, content and an end tag.
Attribute
Extra information inside a tag, such as an image description or a link destination.
Semantic HTML
HTML elements that describe what content does, such as navigation, an article or a heading.
Accessible name
The text or label that tells people using assistive technology what a control is for.
Landmark
A page region, such as main or navigation, that helps people jump to important areas.
Alternative text
A short description that communicates the useful information in an image.
Form validation
Checking that a user’s answers meet the rules before accepting or saving them.
Viewport
The visible area of a web page inside the browser window or on a phone screen.
Canonical URL
The preferred web address for a page when similar or duplicate addresses exist.
In this guide · 10 modules
  1. Key terms in simple language
  2. A valid HTML document
  3. Elements, attributes and nesting
  4. Headings, paragraphs, lists and page outline
  5. Semantic layout landmarks
  6. Links, paths and navigation
  7. Images, audio, video and responsive media
  8. Tables for real tabular data
  9. Forms, labels and native validation
  10. Accessible interaction and built-in elements
  11. Metadata, SEO and safe embedding
  12. Final project
  13. Official references
MODULE 01 / 10 · CONCEPT EXPLAINED

A valid HTML document

HTML is the structure and meaning of a web page; think of it as the frame and room plan of a house. The doctype tells the browser to use modern standards. The html element contains the whole page, head stores information about the page, and body holds the content people see. The charset setting lets the browser display letters and symbols correctly, including text in different languages.

Follow this example
<!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, web</h1>
</body>
</html>
Try it yourself: Create index.html with a title, one heading and one short paragraph; open it in your browser.
MODULE 02 / 10 · CONCEPT EXPLAINED

Elements, attributes and nesting

An element usually has an opening tag, content and a closing tag. Attributes add information in the opening tag, such as href on a link. Nest elements in the correct order and quote attribute values; some elements, such as img and input, are void elements with no closing tag.

Follow this example
<p>Read the <a href="https://developer.mozilla.org/">reference guide</a>.</p>
<img src="/images/keyboard.webp" alt="Compact keyboard on a desk">
Try it yourself: Add a link inside a paragraph and an image with useful alternative text.
MODULE 03 / 10 · CONCEPT EXPLAINED

Headings, paragraphs, lists and page outline

Headings give a page an outline, like the chapter titles in a book. Use one main h1 to say what the page is about, then use h2 and h3 for the sections inside it. Pick a heading because of its meaning, not because you want a certain font size; CSS controls appearance. Paragraphs are for sentences, while ordered and unordered lists make steps and groups easier to scan. This structure also helps screen-reader users move between sections.

Follow this example
<main>
  <h1>Build a portfolio</h1>
  <section aria-labelledby="steps-title">
    <h2 id="steps-title">First steps</h2>
    <ol><li>Choose a project</li><li>Write a plan</li></ol>
  </section>
</main>
Try it yourself: Outline a learning article with one h1, three h2 sections and an ordered checklist.
MODULE 04 / 10 · CONCEPT EXPLAINED

Semantic layout landmarks

Elements such as header, nav, main, article, section and footer communicate each region’s purpose. Use main once for the page’s primary content and nav for a significant group of navigation links. A div is still useful when no semantic element describes the group.

Follow this example
<header><a href="/">Learning Notes</a></header>
<nav aria-label="Primary"><a href="/guides">Guides</a></nav>
<main><article><h1>Semantic HTML</h1><p>Meaning improves navigation.</p></article></main>
<footer>Updated 2026</footer>
Try it yourself: Refactor a page made of divs into landmarks without changing its visible content.
MODULE 05 / 10 · CONCEPT EXPLAINED

Links, paths and navigation

An anchor creates navigation when it has an href. Use descriptive link text that makes sense out of context, prefer stable relative paths for pages in the same site, and reserve buttons for actions. Add a fragment identifier to link directly to a section with a matching id.

Follow this example
<nav aria-label="Guide chapters">
  <a href="#forms">Forms and validation</a>
</nav>
<section id="forms"><h2>Forms</h2></section>
<a href="/learn/python">Python learning guide</a>
Try it yourself: Build a table of contents with three working in-page links.
MODULE 06 / 10 · CONCEPT EXPLAINED

Images, audio, video and responsive media

Use img with meaningful alt text when an image communicates information; use alt="" for purely decorative images. Include width and height to reserve layout space, and offer captions or transcripts when media has spoken content. Use picture and srcset when you need responsive image sources.

Follow this example
<figure>
  <img src="/images/chart.webp" width="800" height="450"
       alt="Monthly sign-ups rise from January to June" loading="lazy">
  <figcaption>Practice project: monthly sign-ups.</figcaption>
</figure>
Try it yourself: Add a responsive image and write alt text that describes the information, not the file name.
MODULE 07 / 10 · CONCEPT EXPLAINED

Tables for real tabular data

Use a table only when data has meaningful rows and columns, not to position page content. Add a caption and header cells so the relationships remain clear to screen readers. Keep complex tables small enough to understand and provide a simpler summary when needed.

Follow this example
<table>
  <caption>Study plan</caption>
  <thead><tr><th scope="col">Week</th><th scope="col">Topic</th></tr></thead>
  <tbody><tr><th scope="row">1</th><td>HTML basics</td></tr></tbody>
</table>
Try it yourself: Represent a three-week learning plan as a table with a caption and correctly scoped headers.
MODULE 08 / 10 · CONCEPT EXPLAINED

Forms, labels and native validation

A label names a form control; connect it with for and the control’s id, or wrap the control. Choose the correct input type for useful browser behavior. Use required, min, max and pattern for simple validation, then validate again on the server because browser checks can be bypassed.

Follow this example
<form action="/signup" method="post">
  <label for="email">Email address</label>
  <input id="email" name="email" type="email" required autocomplete="email">
  <button type="submit">Join</button>
</form>
Try it yourself: Create a sign-up form with a labelled email field, consent checkbox and submit button.
MODULE 09 / 10 · CONCEPT EXPLAINED

Accessible interaction and built-in elements

Prefer native controls because browsers already provide keyboard behavior and accessibility semantics. Use button for an action and anchor for navigation. Add ARIA only when native HTML cannot express the needed role or state, and make every interaction usable with a keyboard.

Follow this example
<details>
  <summary>What does semantic mean?</summary>
  <p>It means the element communicates the purpose of its content.</p>
</details>
<button type="button" aria-expanded="false">Show options</button>
Try it yourself: Try your page using only Tab, Shift+Tab, Enter and Space; fix any control you cannot reach or operate.
MODULE 10 / 10 · CONCEPT EXPLAINED

Metadata, SEO and safe embedding

A useful title and specific description summarize the page in search and browser tabs. Set canonical URLs and social preview metadata for published pages that need them, and keep headings aligned with the actual content. Embeds should use the narrowest permissions necessary; do not paste untrusted HTML into a page.

Follow this example
<head>
  <title>HTML Forms: Labels, Types and Validation</title>
  <meta name="description" content="Learn accessible HTML forms with labelled inputs and native validation.">
  <link rel="canonical" href="https://example.com/learn/html">
</head>
Try it yourself: Give your practice article a unique title, accurate description and stable canonical URL.
PUT THE MODULES TOGETHER

Your final project

Create a semantic, accessible multi-section portfolio page with a working table of contents, labelled contact form and responsive media. Write down what the project should do, build it in small steps, and include a README that explains how to run it.

Find a guided course →

Official documentation and further reading

Use primary documentation for current language rules and version changes. The examples in this guide are learning starting points; verify details for the exact runtime and browser support your project needs.

Frequently asked questions

Is HTML a programming language?

HTML is a markup language: it describes document structure. CSS controls presentation and JavaScript adds behavior.

Should I learn HTML before CSS?

Yes. Learn semantic structure and labels first so you can style real content and build accessible interfaces.