Learn HTML for beginners
Start from zero, with nothing to install. Follow the topics below in order: read a short article, then play its exercises. The daily game brings back what you got wrong until it sticks.
7 topics · 41 articles · 224 exercises · 235 glossary terms
-
Basics
-
The HTML skeleton
5 exercises
Every HTML page has the same basic frame. It tells the browser what kind of file this is and splits it into an invisible head and a visible body.
-
Comments the browser ignores
5 exercises
A comment is a note for people who read the code. The browser skips it and never shows it on the page.
-
Opening and closing tags
6 exercises
Most HTML elements have an opening tag and a closing tag around their content. The closing tag has a slash and must use the same name.
-
Page layout: header, main and footer
9 exercises
Elements like
<header>,<nav>,<main>and<footer>name the big parts of a page. They look like plain blocks, but they tell screen readers and search engines what each part is. -
Attribute basics
5 exercises
Attributes are extra settings written inside an opening tag, like
href="lessons.html". Small mistakes in them, like a missing quote, can break a whole line of the page. -
What may go inside what
4 exercises
HTML elements follow nesting rules that decide which tags may sit inside which. Breaking these rules can make the browser auto-close tags or move elements around.
-
article, section and aside
2 exercises
HTML has three tags for grouping content inside a page:
<article>,<section>, and<aside>. Picking the right one tells browsers and screen readers how each block relates to the rest of the page.
-
The HTML skeleton
5 exercises
-
Head
-
charset, viewport and title
7 exercises
A few lines in the head decide how the page looks on phones and in the browser tab. Visitors never see these lines on the page itself.
-
Loading CSS
4 exercises
The design of a page usually lives in a separate CSS file. A
<link>in the head connects that file to the page. -
Description, link previews and favicon
4 exercises
Some tags in the
<head>are never shown on the page. They give search engines a short description, suggest a preview to chat apps, and point the browser to the small tab icon. -
Canonical links and robots meta
3 exercises
Two optional tags in the
<head>give instructions to search engines. A canonical link names the preferred URL of a page, and a robots meta tag can ask search engines not to index it. -
Loading JavaScript with script
6 exercises
A
<script>tag loads JavaScript so a page can become interactive. Attributes likedefer,asyncandtype="module"control when and how the file runs.
-
charset, viewport and title
7 exercises
-
Text
-
Headings are an outline
5 exercises
Headings
<h1>to<h6>build a table of contents for the page. The number is the level in the outline, not just a font size. -
strong and em
5 exercises
<strong>and<em>give words extra meaning inside a sentence. Browsers show them in bold and in italics by default. -
Lists with ul, ol and li
6 exercises
HTML has two common kinds of lists.
<ul>shows bullet points, and<ol>shows numbers. -
Special characters
5 exercises
Some characters are written as short codes called entities. The browser shows the real character instead of the code.
-
Spaces and line breaks
7 exercises
By default, the browser shows extra spaces and line breaks in text as one space. To break a line or keep spaces, use
<br>,<pre>or . -
Quotes, code and dates
6 exercises
HTML has small tags that say what a piece of text is: a quote, some code, a date or an abbreviation. Browsers style some of them by default, and machines can read them.
-
Nested and description lists
3 exercises
An ordered or unordered list can hold another list inside one of its
<li>items. For pairs like "Price: CHF 80", HTML has the description list<dl>. -
Tables for rows and columns
11 exercises
A table shows data in rows and columns, like a price list or a size chart. It is built row by row:
<tr>makes a row,<th>a heading cell and<td>a normal cell. -
Highlights, edits and small text
3 exercises
HTML has inline tags for highlighted text, edits, outdated info, footnotes and fine print. Browsers give each one a default look so readers can spot its role quickly.
-
b, i and u vs strong and em
2 exercises
<b>,<i>and<u>style words without adding strong importance or spoken stress. Use<strong>and<em>when the meaning matters, and avoid<u>where it looks like a link. -
kbd, samp and var for computer text
2 exercises
HTML has specific inline tags for keyboard input, program output and variable names. Using them makes technical instructions clearer to read and easy to style with CSS.
-
Headings are an outline
5 exercises
-
Links
-
Links and paths
13 exercises
The
hrefof a link says where it goes. It can be a full address or a path that starts from the current page. -
Jump links with #id
5 exercises
A link can jump to a place on the same page. It uses
#plus theidof the target element. -
Opening links in a new tab
2 exercises
target="_blank"asks the browser to open a link in a new tab.reladds safety rules for that new tab. -
Download links and file links
3 exercises
An
<a>link can point to a file like a PDF instead of another web page. Adding thedownloadattribute asks the browser to save a same-site file rather than opening it in the tab. -
Link rel values
2 exercises
The
relattribute on<a>describes how the linked page relates to the current page. You can combine several keywords by separating them with spaces.
-
Links and paths
13 exercises
-
Images
-
Images: alt, width and height
7 exercises
An
<img>needs a few attributes to work well for everyone.altdescribes the image, andwidthandheightkeep space for it. -
Figures, picture and media
14 exercises
<figure>groups an image with its caption, and<picture>offers the browser several image files to choose from.<video>and<audio>play media, andcontrolsadds the browser's built-in play buttons. -
Video captions with track
2 exercises
The
<track>element adds timed text such as captions or subtitles to a<video>or<audio>player. It points to a WebVTT (.vtt) file and tells the browser what kind of text it is and which language it uses.
-
Images: alt, width and height
7 exercises
-
Interactive
-
Buttons, links and details
9 exercises
Links take you somewhere, and buttons do something on the current page.
<details>is a fold-out box that works without any script. -
Form fields and labels
12 exercises
A
<form>collects fields like<input>and<select>and sends them when you tap its submit button. Each field should have a<label>so people and screen readers know what to type. -
Form checks by the browser
6 exercises
By default, the browser checks a form when it is submitted, without any JavaScript. It looks at attributes like
requiredand at the fieldtype, such asemail. -
Content the browser hides
7 exercises
Some HTML is in the file but not on the screen until something shows it.
hidden,<template>, a closed<dialog>and<noscript>all hide content in different ways. -
Input types and controls
3 exercises
The
typeattribute on<input>tells the browser what kind of control to show. Depending on the type, browsers can hide characters, show a slider or date picker, or pick a matching mobile keyboard. -
textarea and datalist
4 exercises
Use <textarea> for multi-line messages and <datalist> to offer autocomplete suggestions on an <input>. Both work with plain HTML and need no JavaScript.
-
Popovers without JavaScript
3 exercises
The
popoverattribute hides a box until a button opens it on top of the page. Withpopovertarget, you can wire up tips, menus and notices using plain HTML.
-
Buttons, links and details
9 exercises
-
Accessibility
-
Names for screen readers
10 exercises
Screen readers read the page out loud. Some elements need an extra name, and some decoration should be skipped.
-
Keyboard focus and tabindex
3 exercises
Many visitors move through a page with the Tab key instead of a mouse or touchscreen. HTML sets a default focus order, and the
tabindexattribute lets you adjust which elements can receive focus. -
Table headers with scope
4 exercises
A table can have headings along the top row and along the left column. Adding
scopeto each<th>tells browsers and screen readers whether that heading labels a column or a row.
-
Names for screen readers
10 exercises