HTML Basics Cheat Sheet

Page skeleton

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Page title</title>
  <meta name="description" content="A short summary of the page.">
</head>
<body>
  <h1>Main heading</h1>
</body>
</html>

Text

TagUse
<h1> to <h6>Headings. Use one h1 per page
<p>Paragraph
<strong> <em>Strong importance and emphasis
<br>Line break
<blockquote>A quotation
<code> <pre>Code, and preformatted text
<a href="/about/">About us</a>
<a href="https://example.com" target="_blank" rel="noopener">External</a>
<img src="photo.jpg" alt="A red bicycle leaning on a wall" width="800" height="600">

Write real alt text, or alt="" for purely decorative images.

Lists and tables

<ul><li>Bullet</li></ul>
<ol><li>Step one</li></ol>

<table>
  <thead><tr><th>Name</th><th>Price</th></tr></thead>
  <tbody><tr><td>Pen</td><td>10</td></tr></tbody>
</table>

Forms

<form action="/send" method="post">
  <label for="email">Email</label>
  <input id="email" name="email" type="email" required>
  <select name="plan"><option value="free">Free</option></select>
  <textarea name="message"></textarea>
  <button type="submit">Send</button>
</form>

Every input needs a label so screen readers and tapping on mobile work.

Semantic layout

TagMeaning
<header>Top of a page or section
<nav>Main navigation links
<main>The main content, once per page
<article>A self-contained piece, such as a post
<section>A themed group of content
<aside>Related side content
<footer>Bottom of a page or section

Special characters

Write &lt; for <, &gt; for >, &amp; for & and &copy; for ©.

↑ ↓ navigateEnter openEsc close