Before you begin
No coding experience required. A text editor and modern browser are enough to create and inspect your first HTML file.
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.
No coding experience required. A text editor and modern browser are enough to create and inspect your first HTML file.
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 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.
<!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>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.
<p>Read the <a href="https://developer.mozilla.org/">reference guide</a>.</p>
<img src="/images/keyboard.webp" alt="Compact keyboard on a desk">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.
<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>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.
<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>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.
<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>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.
<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>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.
<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>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.
<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>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.
<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>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.
<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>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 →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.
HTML is a markup language: it describes document structure. CSS controls presentation and JavaScript adds behavior.
Yes. Learn semantic structure and labels first so you can style real content and build accessible interfaces.