HTML5 Basics Cheat Sheet
This cheat sheet provides a quick reference to the most essential HTML5 elements, attributes, and concepts for beginners. Use it as a handy reference while you're learning to code!
Basic Document Structure
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Page Title</title>
</head>
<body>
<!-- Your content goes here -->
</body>
</html>
Element | Description |
---|---|
<!DOCTYPE html> |
Declares the document as HTML5 |
<html> |
Root element of an HTML page |
<head> |
Contains meta-information about the document |
<meta> |
Defines metadata about the document |
<title> |
Defines the document's title (shown in browser tabs) |
<body> |
Contains the visible content of the document |
Text Elements
Element | Description | Example |
---|---|---|
<h1> to <h6> |
Headings (h1 is most important, h6 is least) | <h1>Main Heading</h1> |
<p> |
Paragraph | <p>This is a paragraph.</p> |
<br> |
Line break (empty element) | Line 1<br>Line 2 |
<hr> |
Horizontal rule (thematic break) | <p>Text</p><hr><p>More text</p> |
<strong> |
Strong importance (typically bold) | <strong>Important text</strong> |
<em> |
Emphasized text (typically italic) | <em>Emphasized text</em> |
<blockquote> |
Block quotation | <blockquote>Quoted text</blockquote> |
<q> |
Inline quotation | He said, <q>Hello!</q> |
<abbr> |
Abbreviation | <abbr title="World Health Organization">WHO</abbr> |
<code> |
Computer code | <code>var x = 5;</code> |
Lists
Unordered List
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>
- Item 1
- Item 2
- Item 3
Ordered List
<ol>
<li>First item</li>
<li>Second item</li>
<li>Third item</li>
</ol>
- First item
- Second item
- Third item
Description List
<dl>
<dt>HTML</dt>
<dd>HyperText Markup Language</dd>
<dt>CSS</dt>
<dd>Cascading Style Sheets</dd>
</dl>
- HTML
- HyperText Markup Language
- CSS
- Cascading Style Sheets
Links and Images
Links
<!-- Basic link -->
<a href="https://example.com">Link text</a>
<!-- Link that opens in a new tab -->
<a href="https://example.com" target="_blank" rel="noopener">Link text</a>
<!-- Link to an email address -->
<a href="mailto:[email protected]">Email us</a>
<!-- Link to a phone number -->
<a href="tel:+1234567890">Call us</a>
<!-- Link to a section within the same page -->
<a href="#section-id">Go to section</a>
Images
<!-- Basic image -->
<img src="image.jpg" alt="Description of the image">
<!-- Image with width and height -->
<img src="image.jpg" alt="Description" width="500" height="300">
<!-- Responsive image -->
<img src="image.jpg" alt="Description" style="max-width: 100%; height: auto;">
<!-- Figure with caption -->
<figure>
<img src="image.jpg" alt="Description">
<figcaption>Caption for the image</figcaption>
</figure>
Tables
<table>
<caption>Monthly Savings</caption>
<thead>
<tr>
<th>Month</th>
<th>Amount</th>
</tr>
</thead>
<tbody>
<tr>
<td>January</td>
<td>$100</td>
</tr>
<tr>
<td>February</td>
<td>$80</td>
</tr>
</tbody>
<tfoot>
<tr>
<td>Total</td>
<td>$180</td>
</tr>
</tfoot>
</table>
Element | Description |
---|---|
<table> |
Defines a table |
<caption> |
Defines a table caption |
<thead> |
Groups header content in a table |
<tbody> |
Groups body content in a table |
<tfoot> |
Groups footer content in a table |
<tr> |
Defines a table row |
<th> |
Defines a header cell |
<td> |
Defines a data cell |
Forms
<form action="/submit" method="post">
<div>
<label for="name">Name:</label>
<input type="text" id="name" name="name" required>
</div>
<div>
<label for="email">Email:</label>
<input type="email" id="email" name="email" required>
</div>
<div>
<label for="message">Message:</label>
<textarea id="message" name="message" rows="4" required></textarea>
</div>
<div>
<input type="checkbox" id="subscribe" name="subscribe" value="yes">
<label for="subscribe">Subscribe to newsletter</label>
</div>
<div>
<button type="submit">Send</button>
<button type="reset">Reset</button>
</div>
</form>
Common Input Types
Input Type | Description | Example |
---|---|---|
text |
Single-line text input | <input type="text"> |
password |
Password input (characters are masked) | <input type="password"> |
email |
Email address input | <input type="email"> |
number |
Numeric input | <input type="number" min="1" max="100"> |
checkbox |
Checkbox (can select multiple) | <input type="checkbox"> |
radio |
Radio button (select one from a group) | <input type="radio" name="group"> |
date |
Date picker | <input type="date"> |
file |
File upload | <input type="file"> |
submit |
Submit button | <input type="submit" value="Submit"> |
Form Attributes
Attribute | Description | Example |
---|---|---|
required |
Specifies that an input field must be filled out | <input type="text" required> |
placeholder |
Short hint that describes the expected value | <input type="text" placeholder="Your name"> |
disabled |
Disables an input element | <input type="text" disabled> |
readonly |
Makes an input element read-only | <input type="text" readonly> |
min /max |
Minimum and maximum values for number inputs | <input type="number" min="1" max="100"> |
pattern |
Regular expression to validate input | <input type="text" pattern="[A-Za-z]{3}"> |
Semantic Elements
Element | Description |
---|---|
<header> |
Container for introductory content or navigation |
<nav> |
Container for navigation links |
<main> |
Main content of the document |
<article> |
Self-contained content that could be distributed independently |
<section> |
Standalone section of a document |
<aside> |
Content indirectly related to the main content |
<footer> |
Footer for a document or section |
<figure> |
Self-contained content (images, diagrams, etc.) |
<figcaption> |
Caption for a figure |
<time> |
Represents a specific time or date |
<mark> |
Marked or highlighted text |
Example Page Structure
<body>
<header>
<h1>Website Title</h1>
<nav>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
</header>
<main>
<article>
<header>
<h2>Article Title</h2>
<p>Published on <time datetime="2023-05-15">May 15, 2023</time></p>
</header>
<section>
<h3>Section Title</h3>
<p>Section content...</p>
</section>
<section>
<h3>Another Section</h3>
<p>More content...</p>
</section>
<footer>
<p>Article footer content</p>
</footer>
</article>
<aside>
<h3>Related Content</h3>
<ul>
<li><a href="#">Related Link 1</a></li>
<li><a href="#">Related Link 2</a></li>
</ul>
</aside>
</main>
<footer>
<p>© 2023 My Website. All rights reserved.</p>
</footer>
</body>
Global Attributes
These attributes can be used with any HTML element:
Attribute | Description | Example |
---|---|---|
id |
Unique identifier for an element | <div id="unique-id"> |
class |
Classifies elements for styling/selection | <div class="container"> |
style |
Inline CSS styling | <p style="color: blue;"> |
title |
Extra information (shown as tooltip) | <p title="Tooltip text"> |
lang |
Language of the content | <p lang="en"> |
hidden |
Hides an element | <div hidden> |
data-* |
Custom data attributes | <div data-user-id="123"> |
tabindex |
Tab order of an element | <a tabindex="1"> |
Comments
<!-- This is a comment -->
<!--
This is a
multi-line comment
-->
Special Characters
Character | Entity | Description |
---|---|---|
< | < |
Less than sign |
> | > |
Greater than sign |
& | & |
Ampersand |
" | " |
Double quotation mark |
' | ' |
Single quotation mark (apostrophe) |
© | © |
Copyright symbol |
® | ® |
Registered trademark symbol |
™ | ™ |
Trademark symbol |
|
Non-breaking space | |
— | — |
Em dash |
Further Resources
- Getting Started with HTML5 - Our comprehensive beginner tutorial
- HTML5 Semantic Elements - In-depth guide to semantic HTML
- HTML5 Forms and Input Types - Detailed tutorial on forms
- HTML5 Semantic Elements Cheat Sheet - PDF download
- HTML5 Forms Cheat Sheet - PDF download