๐ Search the Cheat Sheet
Tip: Use Ctrl+F (Cmd+F on Mac) to search this entire page
๐ Document Structure
| Tag | Purpose |
|---|---|
| <!DOCTYPE html> | Declares HTML5 document |
| <html> | Root element of the page |
| <head> | Metadata container (not visible) |
| <body> | Visible content container |
| <title> | Browser tab title |
| <meta> | Metadata (charset, viewport, etc.) |
| <link> | Links external resources (CSS, favicon) |
| <script> | Embeds JavaScript |
| <style> | Internal CSS |
๐ Text Formatting
| Tag | Purpose |
|---|---|
| <h1> to <h6> | Headings (h1 = most important) |
| <p> | Paragraph |
| <br> | Line break (within same paragraph) |
| <hr> | Thematic break / horizontal line |
| <strong> | Strong importance (bold) |
| <em> | Emphasis (italic) |
| <mark> | Highlighted/marked text |
| <small> | Fine print / legal text |
| <del> | Deleted text (strikethrough) |
| <ins> | Inserted text (underline) |
| <sub> | Subscript |
| <sup> | Superscript |
| <blockquote> | Long quotation |
| <q> | Short inline quotation |
| <cite> | Citation / title of work |
| <abbr> | Abbreviation (use title attr) |
| <code> | Inline code |
| <pre> | Preformatted text (preserves spaces) |
๐ Links & Navigation
| Tag / Attribute | Purpose |
|---|---|
| <a> | Anchor / hyperlink |
| href | Link destination URL |
| target="_blank" | Open in new tab |
| rel="noopener noreferrer" | Security for external links |
| download | Prompt file download |
| title | Tooltip text |
| <nav> | Navigation block |
URL Types:
Absolute:
Relative:
Parent:
Root:
Anchor:
Email:
Absolute:
https://site.com/pageRelative:
page.html or folder/page.htmlParent:
../page.htmlRoot:
/page.htmlAnchor:
#section-idEmail:
mailto:email@site.com
๐ผ๏ธ Images & Media
| Tag / Attribute | Purpose |
|---|---|
| <img> | Image (self-closing) |
| src | Image source path/URL |
| alt | Alternative text (required for accessibility) |
| width / height | Dimensions in pixels |
| loading="lazy" | Defer loading until visible |
| <figure> | Self-contained content |
| <figcaption> | Caption for figure |
| <video> | Video player |
| controls | Show play/pause buttons |
| autoplay | Auto-play (often blocked) |
| loop | Repeat video |
| muted | Start muted |
| poster | Thumbnail image |
| <audio> | Audio player |
| <source> | Media source (inside video/audio) |
๐ Lists
| Tag / Attribute | Purpose |
|---|---|
| <ul> | Unordered list (bullets) |
| <ol> | Ordered list (numbers) |
| start="n" | Start numbering from n |
| reversed | Reverse numbering |
| type="A/a/I/i/1" | Numbering style |
| <li> | List item |
| <dl> | Definition list |
| <dt> | Definition term |
| <dd> | Definition description |
๐ Tables
| Tag / Attribute | Purpose |
|---|---|
| <table> | Table container |
| <caption> | Table title |
| <thead> | Header rows group |
| <tbody> | Body rows group |
| <tfoot> | Footer rows group |
| <tr> | Table row |
| <th> | Header cell |
| scope="col/row" | Header direction (accessibility) |
| <td> | Data cell |
| colspan="n" | Span across n columns |
| rowspan="n" | Span across n rows |
๐ Forms & Input
| Tag / Attribute | Purpose |
|---|---|
| <form> | Form container |
| action | URL to send data |
| method="GET/POST" | HTTP method |
| <input> | Input field (self-closing) |
| type="text" | Single-line text |
| type="email" | Email with validation |
| type="password" | Hidden characters |
| type="tel" | Telephone number |
| type="number" | Numeric input |
| type="date" | Date picker |
| type="time" | Time picker |
| type="checkbox" | Multiple selections |
| type="radio" | Single selection (grouped by name) |
| type="file" | File upload |
| type="hidden" | Invisible data field |
| type="submit" | Submit button |
| type="reset" | Reset button |
| <label> | Label for input (use for + id) |
| <textarea> | Multi-line text input |
| <select> | Dropdown menu |
| <option> | Option in select |
| <fieldset> | Group related fields |
| <legend> | Caption for fieldset |
| <button> | Clickable button |
Validation Attributes:
required โ Must be filledminlength="n" โ Minimum charactersmaxlength="n" โ Maximum charactersmin="n" / max="n" โ Number rangepattern="regex" โ Regex patternplaceholder="text" โ Hint textdisabled โ Non-editablereadonly โ Read-only
๐๏ธ Semantic HTML5
| Tag | Purpose |
|---|---|
| <header> | Introductory content / site header |
| <nav> | Major navigation links |
| <main> | Main content (one per page) |
| <article> | Self-contained content (blog post, card) |
| <section> | Thematic grouping (with heading) |
| <aside> | Tangential content (sidebar) |
| <footer> | Footer for section or page |
| <address> | Contact information |
| <time> | Date/time (use datetime attr) |
| <details> | Disclosure widget (expandable) |
| <summary> | Summary for details |
| <mark> | Highlighted text |
๐ Meta Tags & SEO
| Tag / Attribute | Purpose |
|---|---|
| <meta charset="UTF-8"> | Character encoding |
| <meta name="viewport"> | Mobile responsiveness |
| <meta name="description"> | Search result description |
| <meta name="keywords"> | Keywords (less important now) |
| <meta name="author"> | Page author |
| <meta name="robots"> | Search engine instructions |
| <link rel="canonical"> | Preferred URL (prevents duplicates) |
| <link rel="icon"> | Favicon |
Open Graph (Facebook/LinkedIn):
Twitter Cards:
og:title, og:description, og:image, og:url, og:typeTwitter Cards:
twitter:card, twitter:title, twitter:description, twitter:image
ยฉ HTML Entities
| Character | Entity | Description |
|---|---|---|
| < | < | Less than |
| > | > | Greater than |
| & | & | Ampersand |
| " | " | Double quote |
| ' | ' | Single quote |
| | Non-breaking space | |
| ยฉ | © | Copyright |
| ยฎ | ® | Registered |
| โข | ™ | Trademark |
| โฌ | € | Euro |
| ยฃ | £ | Pound |
| ร | × | Multiply |
| รท | ÷ | Divide |
| โ | — | Em dash |
| โ | – | En dash |
๐ Global Attributes
| Attribute | Purpose |
|---|---|
| class | CSS class name(s) |
| id | Unique identifier (one per page) |
| style | Inline CSS (avoid when possible) |
| title | Tooltip text |
| lang | Language code (e.g., "en", "am") |
| dir | Text direction (ltr/rtl/auto) |
| hidden | Hide element from display |
| data-* | Custom data attributes |
| tabindex | Tab navigation order |
| contenteditable | Make element editable |
โก Quick Start Template
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Page description for SEO">
<title>Page Title | Site Name</title>
<link rel="stylesheet" href="style.css">
<link rel="icon" href="favicon.ico">
</head>
<body>
<header>
<nav>...</nav>
</header>
<main>
<h1>Main Title</h1>
<section>...</section>
</main>
<footer>...</footer>
</body>
</html>
๐ Keyboard Shortcuts
| Action | Windows/Linux | Mac |
|---|---|---|
| Save file | Ctrl + S | Cmd + S |
| Find in page | Ctrl + F | Cmd + F |
| Undo | Ctrl + Z | Cmd + Z |
| Redo | Ctrl + Y / Ctrl + Shift + Z | Cmd + Shift + Z |
| Comment/uncomment line | Ctrl + / | Cmd + / |
| Duplicate line | Shift + Alt + โ | Shift + Option + โ |
| Move line up/down | Alt + โ/โ | Option + โ/โ |
| Format document | Shift + Alt + F | Shift + Option + F |
| Open DevTools | F12 / Ctrl + Shift + I | Cmd + Option + I |
| Inspect element | Ctrl + Shift + C | Cmd + Shift + C |
๐ Useful Resources
- MDN Web Docs โ HTML โ The most comprehensive HTML reference
- W3C Markup Validation Service โ Validate your HTML
- Can I Use โ Check browser support for HTML features
- HTML Living Standard โ The official HTML specification
- WCAG 2.1 Quick Reference โ Web accessibility guidelines