HTML codes and basics: tags, character entities and a page template
HTML is the language of web pages. Browsers read it to decide what is a heading, a paragraph, a link or a table. You can write it in any text editor, and it is worth knowing even if a content system writes most of it for you.
A minimal modern page
<!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>
<link rel="stylesheet" href="style.css">
</head>
<body>
<header><h1>My first page</h1></header>
<main>
<p>Hello. This is a <a href="https://www.unixtools.com/">link</a>.</p>
</main>
<footer><p>© 2026 Me</p></footer>
</body>
</html>
The viewport line makes the page readable on phones, and charset="utf-8" lets you type any character directly. Leave layout and colours to CSS in a separate file.
The tags you will use most
| Tag | Use |
|---|---|
<h1> … <h6> | Headings; one h1 per page, then h2 for sections |
<p> | Paragraph |
<a href="…"> | Link |
<img src="…" alt="…"> | Image; alt describes it for blind users and search engines |
<ul>, <ol>, <li> | Bulleted list, numbered list, list item |
<strong>, <em> | Important text, emphasis |
<code>, <pre> | Code; preformatted block keeping spaces and line breaks |
<table>, <tr>, <th>, <td> | Table, row, header cell, data cell |
<header>, <nav>, <main>, <footer> | Page regions |
<form>, <label>, <input>, <button> | Forms |
<br> | Line break inside a paragraph (rarely needed) |
Older tags such as <font>, <center> and layout tables were replaced by CSS long ago. If you maintain an old site, replace them as you go.
Links, images, lists and tables
<a href="/security.html">Security guide</a>
<a href="https://example.com/" rel="noopener" target="_blank">Opens in a new tab</a>
<a href="mailto:info@example.com">E-mail us</a>
<img src="logo.png" alt="Company logo" width="200" height="80" loading="lazy">
<ul>
<li>First</li>
<li>Second</li>
</ul>
<table>
<thead><tr><th>Command</th><th>Does</th></tr></thead>
<tbody><tr><td>ls</td><td>lists files</td></tr></tbody>
</table>
HTML character codes (entities)
Some characters have a special meaning in HTML and must be written as a code. With UTF-8 you can type most other symbols directly, but the codes are useful when your keyboard lacks them.
| Character | Named code | Number | Description |
|---|---|---|---|
| < | < | < | Less than; must be escaped in text |
| > | > | > | Greater than |
| & | & | & | Ampersand; must be escaped, also in URLs inside attributes |
| " | " | " | Double quote inside an attribute value |
| ' | ' | ' | Apostrophe |
| (space) | |   | Non-breaking space |
| © | © | © | Copyright |
| ® | ® | ® | Registered trademark |
| ™ | ™ | ™ | Trademark |
| € | € | € | Euro |
| £ | £ | £ | Pound sterling |
| ¥ | ¥ | ¥ | Yen |
| ° | ° | ° | Degree |
| ± | ± | ± | Plus or minus |
| × | × | × | Multiplication |
| ÷ | ÷ | ÷ | Division |
| – | – | – | En dash |
| — | — | — | Em dash |
| … | … | … | Ellipsis |
| « » | « » | « » | Angle quotes |
| “ ” | “ ” | “ ” | Curly double quotes |
| → ← | → ← | → ← | Arrows |
| ✓ | ✓ | ✓ | Check mark |
| • | • | • | Bullet |
Any Unicode character can be written by number: decimal € or hexadecimal € both give €. To escape text in a script before putting it into a page, use htmlspecialchars() in PHP or html.escape() in Python; on the command line, sed -e 's/&/\&/g' -e 's/</\</g' -e 's/>/\>/g'.
Check your HTML
- The W3C Markup Validation Service finds missing tags and typos.
- Browser developer tools (F12) show how the browser understood your page.
- Test pages on a phone, and check that images have useful
alttext and that the page can be used with the keyboard alone.
Serving pages from a Unix server
A static site is just HTML files in a directory. To try one locally, run python3 -m http.server 8000 in that directory and open http://localhost:8000/. For the real thing, see setting up a web server and web hosting basics.
Learn more
- MDN: Learn web development: the best free course on HTML, CSS and JavaScript.
- MDN HTML element reference.
- The full list of named character references in the HTML standard.
- web.dev Learn HTML.