Page structure
<html>
Wraps the whole page. Set the language here.
<!doctype html> <html lang="en"> ... </html>
<head>
Holds the title, meta tags and styles. Nothing here shows in the page.
<head> <title>Club handout</title> </head>
<title>
The text on the browser tab and in search results.
<title>HTML Cheat Sheet</title>
<meta>
Page settings. The viewport line makes phones use the real screen width.
<meta charset="utf-8"> <meta name="viewport" content="width=device-width,initial-scale=1">
<body>
Everything a visitor sees goes inside body.
<body> <p>Hello</p> </body>
<header>
The top part of a page or a section: logo, title, menu.
<header> <strong>Riverside Coding Club</strong> </header>
<main>
The main content. Use one per page.
<main> <p>This week: lists.</p> </main>
<footer>
The bottom part: contact, dates, small print.
<footer> <small>Updated Week 1</small> </footer>
Text
<h1> to <h6>
Headings. One h1 for the page title, then h2, h3 in order.
<h1>Club night</h1> <h2>What to bring</h2>
Club night
What to bring
<p>
A paragraph. The browser adds space above and below.
<p>Bring a laptop.</p>
Bring a laptop.
<strong>
Important text. Shows bold.
<strong>Doors close at 6:15.</strong>
<em>
Stress on a word. Shows italic.
Save the file <em>before</em> you close it.
<br>
A line break inside one block, like an address. No closing tag.
12 River Road<br>Room 4
Room 4
<span>
Marks a few words so you can style them. Means nothing on its own.
Status: <span style="color:green">open</span>
<blockquote>
A quote taken from somewhere else.
<blockquote>Start small.</blockquote>
Start small.
<code>
Code inside a sentence. Wrap it in pre for a block that keeps spaces.
Type <code><p></code> to start.
<p> to start.Links and images
<img>
An image. Always write alt text. Give width and height.
<img src="logo.png" alt="Club logo" width="60" height="60">
<figure>
An image or chart with a caption under it.
<figure> <img src="map.png" alt="Room map"> <figcaption>Room 4 is upstairs.</figcaption> </figure>
<svg>
A drawing made of shapes. Stays sharp at any size.
<svg width="40" height="40">
<circle cx="20" cy="20" r="16"
fill="orange"/>
</svg>Lists and tables
<ul> and <li>
A bullet list. Each item is an li.
<ul> <li>Laptop</li> <li>Charger</li> </ul>
- Laptop
- Charger
<ol>
A numbered list, for steps in order.
<ol> <li>Open the editor</li> <li>Save as index.html</li> </ol>
- Open the editor
- Save as index.html
<table>
Rows (tr) of cells (td). Use th for header cells.
<table> <tr><th>Week</th><th>Topic</th></tr> <tr><td>1</td><td>Tags</td></tr> </table>
| Week | Topic |
|---|---|
| 1 | Tags |
<details>
A box that opens on click. No JavaScript needed.
<details> <summary>Answer</summary> Use an ol. </details>
Answer
Use an ol.<div>
A plain box for layout. Use a meaning tag first if one fits.
<div style="padding:8px; background:#eef">Note</div>
Forms
<form>
Groups inputs. action is where answers are sent. A plain page has nowhere to send them.
<form action="/signup"> ... </form>
<label>
Names an input. Clicking the label focuses the box.
<label for="nm">Name</label> <input id="nm">
<input>
One field. type changes it: text, email, date, checkbox.
<input type="checkbox" id="ok"> <label for="ok">I'll be there</label>
<button>
A clickable button. Inside a form it submits by default.
<button type="button">Show hint</button>
<select>
A drop-down list of options.
<select> <option>Beginner</option> <option>Some HTML</option> </select>
No tag matches that filter.