β All cheat sheets
π
HTML Cheat Sheet
A quick-reference HTML cheat sheet covering tags, structure, forms, links, images, and semantic elements.
Document Structure
<!DOCTYPE html>Declares an HTML5 document<html lang='en'></html>Root element with language<head></head>Metadata container (not rendered)<body></body>Visible page content<meta charset='utf-8'>Sets character encoding<meta name='viewport' content='width=device-width, initial-scale=1'>Responsive viewport for mobile<title>Page Title</title>Tab and bookmark title<link rel='stylesheet' href='style.css'>Links an external stylesheetText & Headings
<h1>Main Heading</h1>Top-level heading<h2>...</h2> ... <h6>...</h6>Subheadings h2 to h6<p>Paragraph text.</p>Block of paragraph text<strong>Important</strong>Strong importance (bold)<em>Emphasis</em>Emphasized text (italic)<br>Line break<hr>Thematic horizontal rule<blockquote>Quoted text</blockquote>Block quotationLists
<ul><li>Item</li></ul>Unordered (bulleted) list<ol><li>Item</li></ol>Ordered (numbered) list<li>List item</li>A single list item<ol start='5'>...</ol>Start numbering at a value<dl></dl>Description list container<dt>Term</dt>Term in a description list<dd>Definition</dd>Definition of the termLinks & Images
<a href='/'>Home</a>Hyperlink to a URL or path<a href='https://x.com' target='_blank' rel='noopener'>External</a>Open in a new tab safely<a href='#section'>Jump</a>Anchor to an in-page id<a href='mailto:hi@x.com'>Email</a>Email link<img src='photo.jpg' alt='A description'>Image with required alt text<img src='small.jpg' srcset='large.jpg 2x'>Responsive image sourcesTables
<table></table>Table container<thead></thead>Groups header rows<tbody></tbody>Groups body rows<tr></tr>Table row<th scope='col'>Name</th>Header cell<td>Value</td>Standard data cell<td colspan='2'>Wide</td>Cell spanning multiple columnsForms
<form action='/submit' method='post'></form>Form that submits data<label for='name'>Name</label>Label linked to an input id<input type='text' id='name' name='name'>Text input<input type='email' required>Email input with validation<input type='checkbox' name='ok'>Checkbox; also radio, date, file<textarea rows='4'></textarea>Multi-line text input<select><option value='a'>A</option></select>Dropdown with options<button type='submit'>Send</button>Submit buttonSemantic Layout
<header></header>Introductory content or banner<nav></nav>Navigation links<main></main>Primary unique page content<section></section>Thematic grouping of content<article></article>Self-contained, reusable content<aside></aside>Sidebar or tangential content<footer></footer>Footer for its nearest section<figure><figcaption>Caption</figcaption></figure>Media with a captionMedia & Embeds
<audio src='song.mp3' controls></audio>Audio player with controls<video src='clip.mp4' controls></video>Video player with controls<source src='clip.webm' type='video/webm'>Alternate media source<track kind='captions' src='caps.vtt'>Captions for video or audio<iframe src='https://x.com' title='Embed'></iframe>Embeds another pageCommon Attributes
<div id='main'></div>Unique element identifier<div class='card box'></div>Space-separated CSS classes<p style='color:red'>Hi</p>Inline CSS styling<div data-user-id='42'></div>Custom data-* attribute<a href='/path'>Link</a>Destination URL for links<img src='pic.png' alt='Pic'>Resource source and alt text<input title='Helpful hint'>Tooltip text on hoverReading is good β doing is better. Practice HTML with interactive, auto-graded lessons.
Start learning HTML