ā¤ Like
šŸ”– Save
šŸ”— Share
@thedevspaceio
@thedevspaceio

The Ultimate HTML Cheatsheet

The Ultimate HTML Cheatsheet

Document

An overview of the top-level elements that form an HTML document.

ElementDescription
<!DOCTYPE html>Declares HTML5 document type.
<html>Root element. Contains <head> and <body>.
<head>Document metadata container.
<title>Document title shown in browser UI.
<base>Base URL for relative links.
<meta>Metadata: charset, viewport, description, etc.
<link>External resources (stylesheets, preconnect).
<style>In page CSS.
<script>JavaScript code or reference.
<body>Document body; visible content.

Document metadata

The <head> section of an HTML document.

ElementCommon attributes / notes
<meta>charset, name, content, http-equiv (e.g., viewport)
<link>rel, href, crossorigin, integrity, media
<base>href, target
<title>The main title of the document
<noscript>Fallback content when scripting is disabled

Sectioning & headings

ElementDescription
<header>Intro or navigational aids for a page/section.
<nav>Navigation links.
<main>Main content of the document (unique).
<section>Thematic grouping of content.
<article>Independent, self-contained composition.
<aside>Tangential content (sidebars, pull-quotes).
<footer>Footer for a page or section.
<h1>–<h6>Headings (semantic hierarchy).
<address>Contact information/authoring contact.

Grouping content

ElementDescription
<p>Paragraph.
<hr>Thematic break.
<pre>Preformatted text (preserves whitespace).
<blockquote>Section quoted from another source.
<figure>Self-contained content, often with <figcaption>.
<figcaption>Caption for a <figure>.
<div>Generic container (non-semantic).
<template>inert DOM for client-side templating.
<slot>Web component insertion point.

Text-level semantics

ElementDescription
<a>Hyperlink. href, target, rel, download.
<em>Emphasis (usually italic).
<strong>Strong importance (usually bold).
<small>Side comment, fine print.
<cite>Reference to a creative work.
<code>Inline code snippet.
<var>Variable or placeholder.
<samp>Sample output from a program.
<kbd>User input (keyboard).
<sub>, <sup>Subscript / superscript.
<br>Line break.
<wbr>Optional word break.
<span>Generic inline container.
<mark>Highlighted text.
<abbr>Abbreviation, optionally title for expansion.
<data>Machine-readable value (with value attribute).
<time>Date/time, datetime attribute.

Embedded & media

ElementDescription
<img>Image. src, alt, srcset, sizes, loading.
<picture>Responsive images with <source> children.
<source>Source for <picture>, <audio>, or <video>.
<figure>Figure with optional <figcaption>.
<svg>Inline SVG (graphics).
<canvas>Scripted drawing surface.
<iframe>Inline browsing context. src, sandbox, allow.
<video>Video player. controls, autoplay, muted, playsinline.
<audio>Audio player. controls, autoplay, loop.
<track>Subtitles/captions for media.
<embed>External content (often PDF, plugins).
<object>Embeds external resources; <param> children.
<param>Parameters for <object>.
<map> / <area>Image maps.

Lists & tables

ElementDescription
<ul>Unordered list.
<ol>Ordered list.
<li>List item.
<dl>Description list.
<dt>Term/name in a description list.
<dd>Description of the term.
<table>Table container.
<caption>Table caption.
<thead>, <tbody>, <tfoot>Table sections.
<tr>Table row.
<th>Table header cell.
<td>Table data cell.

Forms & inputs

ElementCommon attributes / notes
<form>action, method, enctype, novalidate.
<fieldset>Groups related controls; use <legend> for label.
<legend>Caption for <fieldset>.
<label>Labels a control; for attribute or wrapping.
<input>Input filed for the form. Attributes and types see below.
<button>type (button, submit, reset), disabled.
<select>Dropdown. Use <option>, <optgroup>.
<option>value, selected, disabled.
<datalist>Autocomplete options for inputs.
<textarea>rows, cols, maxlength, placeholder.
<output>Result of a calculation.
<progress>Progress bar with value and max.
<meter>Scalar measurement within a known range.

Scripting & templating

ElementNotes
<script>src, type, async, defer, nomodule, integrity, crossorigin.
<noscript>Fallback when JS disabled.
<template>Client-side templates (content inert until cloned).
<slot>Web components content insertion point.

Interactive & ARIA

ElementNotes
<details>Disclosure widget; contains <summary>.
<summary>Summary/label for a <details> element.
<dialog>Modal or non-modal dialog (use JS to control).
<menu>Context or list of commands (use carefully).
<a>With href becomes focusable/interactive; download to save.

Accessibility & ARIA notes:

  • Prefer semantic elements (buttons, links, headings) over generic <div>/<span>.
  • Use aria-* only when native semantics cannot be used; add role when necessary.
  • Add alt for images, label/aria-label for controls, and title sparingly.

Global attributes

Common attributes available on most HTML elements.

AttributeDescription
idUnique element identifier.
classSpace-separated list of classes.
styleInline CSS styles (prefer external CSS).
titleAdvisory tooltip text.
langElement language.
dirText direction (ltr, rtl, auto).
hiddenBoolean — element is not relevant/hidden.
data-*Custom data attributes for JS.
contenteditableEditable by the user.
tabindexKeyboard navigation order and focusability.
draggableDrag-and-drop.
spellcheckWhether to check spelling.
accesskeyKeyboard shortcut.

Common form attributes

Common attributes for form controls and <input> specifically.

AttributeNotes
typeInput type (see types table below).
nameKey for the control when submitting forms.
idIdentifier for labels and scripting.
valueCurrent value of the control.
placeholderShort hint shown when the field is empty.
requiredBoolean — field must be filled before submit.
readonlyField is read-only but focusable/selectable.
disabledField is disabled — not submitted and not focusable.
min, maxNumeric/date boundaries for validation.
stepGranularity for numeric/date inputs.
patternRegex for client-side validation.
autocompleteHints for autofill (on, off, or specific tokens).
multipleAllows multiple values (e.g., for file input or email).
acceptFile types accepted by a file input (MIME or extensions).
checkedFor checkbox and radio, indicates initial checked state.
formAssociate control with a form by id (useful outside the form).
inputmodeHints to mobile keyboards (numeric, email, tel, etc.).
aria-*ARIA attributes for accessibility when native semantics are insufficient.

Input types & attributes

Common <input> types and what they are used for.

TypeDescriptionExample
textSingle-line text input for general strings.
searchText optimized for search queries (may show clear button).
passwordObscured text for passwords.
emailEmail address. Enables validation and appropriate keyboard on mobile.
telTelephone number. Numeric keyboard on mobile.
urlURL. Validation and specialized keyboard.
numberNumeric input with optional min/max/step.
rangeSlider control for numeric ranges.
dateNative date picker (browser implementation).
timeTime input.
datetime-localDate and time input without timezone.
monthMonth picker.
weekWeek picker.
colorColor picker.
checkboxBinary on/off control.
radioSelect one option from a named group.
fileFile chooser.
submitSubmit the form.
resetReset form fields to initial values.
buttonGeneric button (useful with JS).

Event attributes (inline handlers)

Commonly used inline event attributes (prefer addEventListener in JS).

AttributeTrigger
onclickMouse click.
ondblclickDouble click.
onmousedown, onmouseup, onmousemoveMouse actions.
onkeydown, onkeyup, onkeypressKeyboard actions.
oninputValue changes for input/textarea.
onchangeChange event for inputs, selects.
onsubmitForm submission.
onfocus, onblurFocus changes.
onload, onerrorResource load/error (window, img, script).