Skip to content
Resources

Web Development Cheat Sheets: HTML, CSS, JS & More

Concise web development cheat sheets for HTML, CSS, JavaScript, PHP and WordPress, Elementor and WooCommerce, SEO, website speed and Core Web Vitals, DNS and SSL, Git and accessibility. Each is a compact on-page reference linking to deeper guides where available. Always confirm details against current official documentation.

Web development cheat sheets: desk with laptop, notebook and a printed web design cheat sheet
Quick answer

These cheat sheets are quick, accurate references for everyday web work: HTML elements and attributes, CSS selectors, Flexbox and Grid, JavaScript syntax, PHP and WordPress functions, SEO tags, Core Web Vitals thresholds, DNS records and common Git commands. Bookmark the page and use your browser’s search (Ctrl+F or Cmd+F) to jump to what you need.

Cheat Sheet Categories

HTML Cheat Sheets

Tags, forms, semantics

CSS Cheat Sheets

Selectors, box model, layout

JavaScript Cheat Sheets

Syntax, arrays, async, DOM

PHP Cheat Sheets

Arrays, functions, types

WordPress Cheat Sheets

Hooks, WP_Query, enqueueing

Elementor Cheat Sheets

Containers, Theme Builder

SEO Cheat Sheets

On-page, technical, measurement

Technical SEO Cheat Sheets

Crawl, index, status codes

Website Speed Cheat Sheets

Images, caching, JS

Core Web Vitals Cheat Sheets

LCP, INP, CLS thresholds

Hosting & DNS Cheat Sheets

Records, SSL, propagation

Forms & Accessibility Cheat Sheets

Labels, focus, contrast

Git & Command Line Cheat Sheets

Everyday commands

Website Design Cheat Sheets

Responsive and accessible basics

WooCommerce Cheat Sheets

Products, variations, checkout

Web Development Tools Cheat Sheets

Quick lookup tables

On-page reference

HTML Tags Cheat Sheet

For: Beginners. Topics: Structure, semantics, forms. View on this page On-page reference

CSS Properties Cheat Sheet

For: Designers, developers. Topics: Box model, typography. View on this page On-page reference

CSS Flexbox Cheat Sheet

For: Front-end devs. Topics: Axes, alignment, wrapping. View on this page On-page reference

CSS Grid Cheat Sheet

For: Front-end devs. Topics: Tracks, areas, minmax. View on this page On-page reference

JavaScript Syntax Cheat Sheet

For: Developers. Topics: Functions, arrays, async. View on this page On-page reference

WordPress Functions Cheat Sheet

For: WP developers. Topics: Hooks, queries, enqueue. View on this page On-page reference

SEO Checklist Cheat Sheet

For: SEOs, writers. Topics: Titles, headings, indexing. View on this page On-page reference

Website Speed Reference

For: Developers. Topics: Images, caching, JS. View on this page On-page reference

Core Web Vitals Cheat Sheet

For: Everyone. Topics: LCP, INP, CLS. View on this page On-page reference

DNS Records Cheat Sheet

For: Site owners. Topics: A, CNAME, MX, TXT. View on this page On-page reference

Git Commands Cheat Sheet

For: Developers. Topics: Status, commit, branch. View on this page On-page reference

HTML Accessibility Cheat Sheet

For: Everyone. Topics: Labels, alt text, focus. View on this page

HTML Cheat Sheet

Semantic elements (header, nav, main, article, section, aside, footer) describe meaning; div and span are generic containers with no meaning. Avoid obsolete elements such as <font> or <center>. See our HTML guide.

Document structure

<!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="Short summary">
  <link rel="stylesheet" href="styles.css">
</head>
<body>
  <header>…</header>
  <main>…</main>
  <footer>…</footer>
  <script src="app.js" defer></script>
</body>
</html>

Text, links, images and lists

<h1>Main heading</h1>
<p>Paragraph with <a href="/about/">a descriptive link</a>.</p>
<img src="team.webp" alt="Our team at the office"
     width="800" height="533">
<img src="divider.svg" alt="">  <!-- decorative -->
<ul>
  <li>Unordered item</li>
</ul>
<ol>
  <li>Ordered step</li>
</ol>

Use empty alt only for decorative images.

Forms

<form action="/contact" method="post">
  <label for="email">Email</label>
  <input id="email" name="email" type="email"
         autocomplete="email" required>
  <label for="msg">Message</label>
  <textarea id="msg" name="message"></textarea>
  <button type="submit">Send</button>
</form>

Common input types: text, email, tel, url, number, date, checkbox, radio, password, search.

Tables and entities

<table>
  <caption>Plan comparison</caption>
  <thead>
    <tr><th scope="col">Plan</th><th scope="col">Price</th></tr>
  </thead>
  <tbody>
    <tr><td>Basic</td><td>&hellip;</td></tr>
  </tbody>
</table>
&amp;  &lt;  &gt;  &quot;  &copy;  &nbsp;

Use tables for tabular data, not layout.

CSS Cheat Sheet

Which declaration wins depends on cascade layers, specificity, source order and inheritance. Fix conflicts by understanding these, not by defaulting to !important. See our CSS guide.

Selectors and specificity

p { }               /* type: 0-0-1 */
.card { }           /* class: 0-1-0 */
#main { }           /* id: 1-0-0 */
.nav a:hover { }    /* 0-2-1 */
ul > li { }         /* child */
h2 + p { }          /* adjacent sibling */
a[href^="https"] { }/* attribute */
.btn::before { }    /* pseudo-element */

Box model, colour and type

*, *::before, *::after { box-sizing: border-box; }
.box {
  margin: 1rem auto;
  padding: 1rem 1.5rem;
  border: 1px solid #dce8f5;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgb(0 0 0 / 0.08);
  color: #0f172a;
  font: 400 1rem/1.6 Inter, sans-serif;
}

Flexbox

.row {
  display: flex;
  flex-direction: row;      /* main axis */
  flex-wrap: wrap;
  justify-content: space-between; /* main axis */
  align-items: center;      /* cross axis */
  gap: 1rem;
}
.row > .item { flex: 1 1 200px; } /* grow shrink basis */

Grid

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: 1rem;
}
.layout {
  display: grid;
  grid-template-areas: "header header" "nav main";
  grid-template-columns: 200px 1fr;
}
.layout header { grid-area: header; }

Positioning and display

.badge { position: absolute; top: 0; right: 0; }
.parent { position: relative; }
.sticky { position: sticky; top: 0; }
.hidden { display: none; }
.inline { display: inline-block; }

Responsive, custom properties, motion

@media (min-width: 768px) {
  .grid { grid-template-columns: 1fr 1fr; }
}
:root { --brand: #1562b1; }
.btn { background: var(--brand); transition: background 0.2s ease; }
.btn:hover, .btn:focus-visible { background: #0d4a8a; }
@media (prefers-reduced-motion: reduce) {
  .btn { transition: none; }
}

JavaScript Cheat Sheet

Core language syntax works everywhere; document and window are browser APIs, while modules such as fs are Node.js APIs. See our JavaScript guide.

Variables, types and operators

const name = "Ana";      // cannot be reassigned
let count = 0;            // can be reassigned
// string, number, bigint, boolean, undefined, null, symbol, object
count += 1;
const isAdult = age >= 18 && hasId;
const label = value ?? "default"; // nullish coalescing
const city = user?.address?.city;  // optional chaining

Conditionals, loops, functions

if (score > 90) {
  grade = "A";
} else {
  grade = "B";
}
for (const item of items) { console.log(item); }
function add(a, b) { return a + b; }
const double = (n) => n * 2;
const greet = `Hello, ${name}!`;  // template literal

Arrays, objects, destructuring

const nums = [1, 2, 3, 4];
nums.map((n) => n * 2);        // [2, 4, 6, 8]
nums.filter((n) => n % 2 === 0); // [2, 4]
nums.reduce((sum, n) => sum + n, 0); // 10
nums.find((n) => n > 2);       // 3
const user = { id: 1, name: "Ana" };
const { name: userName } = user;
const copy = { ...user, active: true };

Async, errors and JSON

async function loadPosts() {
  try {
    const res = await fetch("/wp-json/wp/v2/posts");
    if (!res.ok) throw new Error(`HTTP ${res.status}`);
    const posts = await res.json();
    return posts;
  } catch (err) {
    console.error(err);
    return [];
  }
}
JSON.stringify({ a: 1 }); // '{"a":1}'
JSON.parse('{"a":1}');   // { a: 1 }

DOM and events (browser)

const btn = document.querySelector(".menu-toggle");
const items = document.querySelectorAll(".item");
btn.addEventListener("click", () => {
  const open = btn.getAttribute("aria-expanded") === "true";
  btn.setAttribute("aria-expanded", String(!open));
});
el.textContent = userInput; // safer than innerHTML for text

Modules

// math.js
export function sum(a, b) { return a + b; }
export default function multiply(a, b) { return a * b; }
// app.js
import multiply, { sum } from "./math.js";
<!-- in HTML -->
<script type="module" src="app.js"></script>

PHP and WordPress Cheat Sheets

Test code in the relevant PHP and WordPress versions, on staging, with backups. Never edit WordPress core files; use a child theme or plugin. Escape output, sanitise input and check capabilities. See our WordPress guide and PHP guide.

PHP basics

<?php
declare(strict_types=1);
$name = "Ana";
$items = ["a", "b"];
$user = ["id" => 1, "role" => "editor"];
function greet(string $name): string {
    return "Hello, " . $name;
}
foreach ($items as $i => $item) {
    echo $i . ": " . $item . PHP_EOL;
}
if (isset($user["role"]) && $user["role"] === "editor") { /* ... */ }
try {
    risky();
} catch (Exception $e) {
    error_log($e->getMessage());
}

Actions and filters

// Action: run code at a point
add_action( 'init', 'myprefix_register_types' );
// Filter: modify and return a value
add_filter( 'excerpt_length', function ( $length ) {
    return 30;
} );

Actions run code; filters receive a value and must return it.

Enqueue scripts and styles

add_action( 'wp_enqueue_scripts', function () {
    wp_enqueue_style(
        'mytheme-style',
        get_stylesheet_uri(),
        array(),
        '1.0'
    );
    wp_enqueue_script(
        'mytheme-app',
        get_stylesheet_directory_uri() . '/js/app.js',
        array(),
        '1.0',
        array( 'strategy' => 'defer' )
    );
} );

The strategy argument requires WordPress 6.3 or later.

WP_Query and template tags

$q = new WP_Query( array(
    'post_type'      => 'post',
    'posts_per_page' => 5,
) );
if ( $q->have_posts() ) {
    while ( $q->have_posts() ) {
        $q->the_post();
        printf(
            '<a href="%s">%s</a>',
            esc_url( get_permalink() ),
            esc_html( get_the_title() )
        );
    }
    wp_reset_postdata();
}

Shortcode with escaping

add_shortcode( 'greeting', function ( $atts ) {
    $atts = shortcode_atts(
        array( 'name' => 'friend' ),
        $atts
    );
    return '<p>Hello, ' . esc_html( $atts['name'] ) . '</p>';
} );
// Usage: [greeting name="Ana"]

Child theme, plugin header, REST

/* style.css (child theme) */
/*
Theme Name: My Child Theme
Template:   parent-theme-folder
*/
<?php
/*
 * Plugin Name: My Plugin
 * Version:     1.0.0
 */
// REST API: list posts
// GET /wp-json/wp/v2/posts
// Capability check
if ( current_user_can( 'manage_options' ) ) { /* ... */ }

Template hierarchy: WordPress picks the most specific template file, e.g. single-{post-type}.php, then single.php, then singular.php, then index.php.

Elementor and WooCommerce References

ElementorQuick reference
ContainersFlexbox (and grid) layout blocks; nest for columns
Responsive controlsPer-breakpoint values for many settings
Global colors and fontsSite Settings for consistent styles
Theme BuilderHeaders, footers, single and archive templates (Elementor Pro)
Template importTemplates panel → Import; check required widgets
Free vs ProSome widgets and features need Pro
Third-party add-onsSeparate plugins, not part of Elementor
WooCommerceQuick reference
Product typesSimple, variable, grouped, external/affiliate
Attributes and variationsAttributes (e.g. size) create variations of a variable product
Cart and checkoutDedicated pages; block-based versions available
HooksWooCommerce provides its own actions and filters; check developer docs before use
ExtensionsPayments, shipping, subscriptions from WooCommerce Marketplace
ConflictsTest on staging: default theme, plugins one at a time

Elementor features are separate from WordPress core and third-party add-ons. We do not list undocumented selectors or hooks; consult official documentation.

SEO Cheat Sheet

On-pageReminder
Page titleUnique, descriptive <title>
Meta descriptionAccurate summary; Google may rewrite
HeadingsOne H1, logical H2/H3
Internal linksDescriptive anchor text
Image altDescribe meaningful images
Search intentMatch what searchers need
UsefulnessOriginal, accurate, helpful content
Canonical<link rel=”canonical”> to preferred URL
TechnicalReminder
CrawlabilityLinks reachable; not blocked in robots.txt
IndexabilityNo unintended noindex
XML sitemapCanonical, indexable URLs
Robots directivesrobots.txt vs meta robots
Redirects301 permanent, 302 temporary
Status codes200 OK, 301, 404, 410, 500
Structured dataJSON-LD, validate with Rich Results Test
MobileResponsive, readable on phones

Measurement: Search Console (impressions, clicks), analytics and conversions, plus regular audits. Metadata and checklists do not guarantee rankings, and search engines may choose their own title links and snippets. See website SEO.

Website Speed and Core Web Vitals

MetricWhat it measures“Good” threshold
LCPLargest Contentful Paint: loading≤ 2.5 s
INPInteraction to Next Paint: responsiveness≤ 200 ms
CLSCumulative Layout Shift: visual stability≤ 0.1

Thresholds per Google’s web.dev guidance, assessed at the 75th percentile of page loads. FID is no longer a Core Web Vital. TTFB is a diagnostic metric, not a Core Web Vital.

TopicReminder
Lab vs fieldLighthouse simulates; CrUX/RUM measures real users
ToolsPageSpeed Insights, Lighthouse, DevTools
ImagesRight size, modern formats, dimensions set
Caching and CDNReduce repeat work and distance
FontsFew weights, font-display, preload only critical
JavaScriptDefer non-critical, cut long tasks
Render-blockingInline critical CSS, defer the rest

Hosting, DNS and SSL References

RecordPurposeCommon use
AName → IPv4 addressPoint domain to server
AAAAName → IPv6 addressIPv6 hosting
CNAMEAlias to another hostnamewww → host target (not at apex in standard DNS)
MXMail servers for the domainEmail hosting
TXTText dataSPF, DKIM, DMARC, verification
NSAuthoritative name serversDelegating DNS
CAAWhich CAs may issue certificatesCertificate control
Security dashboard screenshot illustrating “Hosting, DNS and SSL References”

Propagation time varies with TTL and resolver caching; it is not a fixed duration. Domain registration and hosting are separate services. HTTPS uses TLS certificates to encrypt traffic. Verify intended values before changing production DNS, because mistakes can take sites or email offline. See Cloudflare and CDN.

Git and Command-Line Cheat Sheet

git init                  # start a repository
git status                # see changed files
git add file.txt          # stage a file
git commit -m "Message"   # record staged changes
git log --oneline         # compact history
git branch feature-x      # create a branch
git switch feature-x      # move to a branch
git diff                  # unstaged changes
git merge feature-x       # merge into current branch
git pull                  # fetch and integrate remote
git push origin main      # upload commits

Caution: commands such as git reset --hard, git clean -fd or git push --force discard work or rewrite shared history; understand them before use. Shell syntax differs between Bash/zsh and Windows PowerShell or Command Prompt.

Accessibility and Responsive Design References

A short reference cannot establish full accessibility compliance, and automated tools cannot detect every issue. See website accessibility and responsive design.

Quick Lookup Tables

Table A: HTML elements

ElementPurposeCommon use
<main>Primary contentOnce per page
<nav>Navigation linksMenus
<article>Self-contained contentPosts, cards
<section>Thematic groupPage sections with headings
<button>Action controlForms, toggles

Table B: CSS layout

TechniquePurposeApplication
display: flex1D layoutRows of items
display: grid2D layoutPage and card grids
position: stickyStick on scrollHeaders
clamp()Fluid valuesResponsive type
aspect-ratioReserve spaceMedia

Table C: JavaScript methods

MethodPurposeConsideration
map()Transform each itemReturns new array
filter()Keep matching itemsReturns new array
reduce()Combine to one valueProvide initial value
querySelector()Find elementReturns null if none
addEventListener()Handle eventsRemove when no longer needed

Table D: SEO terminology

TermMeaningUseful for
CanonicalPreferred URL versionDuplicates
NoindexExclude from indexThin or private pages
Crawl budgetCrawl capacity and demandLarge sites
SERPResults pageSnippet review
Structured dataMachine-readable infoRich result eligibility

Table E: Website performance

MetricMeasuresInvestigate with
LCPMain content loadPSI, DevTools Performance
INPInteraction delayField data, DevTools
CLSLayout shiftsDevTools Rendering
TTFBServer response (diagnostic)Network panel

Table F: DNS records

RecordPurposeUse
A / AAAAAddressHosting
CNAMEAliasSubdomains
MXMailEmail
TXTTextVerification, SPF
CAACA authorisationCertificates

How to Use Cheat Sheets Effectively

Seven-step workflow for using cheat sheets

01

Identify the task or problem

02

Open the relevant reference

03

Check against current documentation

04

Adapt to project requirements

05

Test in a safe environment

06

Review accessibility, security, compatibility

07

Document project-specific changes

Cheat sheets support learning and quick lookup but do not replace documentation, testing or code review.

On-Page vs Downloadable References

FormatStatus on this page
On-page referenceAvailable here now
Printable guidePrint this page from your browser
PDFNot currently offered
Image referenceNot currently offered
Snippet collectionCode blocks on this page
Downloadable fileNot currently offered
Interactive lookup toolNot currently offered

Common Cheat Sheet Mistakes

Outdated syntax

Check current docs.

Copying without understanding

Read each line.

Ignoring browser support

Check compatibility tables.

Untested snippets

Test on staging.

Core vs plugin confusion

Know where features come from.

Outdated SEO terms

FID is no longer a Core Web Vital.

!important everywhere

Fix specificity instead.

Running unknown commands

Understand effects first.

Copying DNS records from other setups

Use your provider’s values.

Ignoring accessibility and security

Review before shipping.

Keep learning

More in Resources

Checklists

Practical website checklists for design, launch, SEO, security and maintenance that you can follow one step at a time.

Web Design Resources

A curated list of free, high-quality web design resources: fonts, icons, stock photos, illustrations, colour tools, UI kits, inspiration and…

Web Design & Development Glossary

A web design glossary of plain-English definitions for the web design, development, hosting and SEO terms you will see in…

FAQ

Web development cheat sheets: your questions answered

Short, honest answers to the questions people ask most about this topic.

Can I download these cheat sheets?

They are designed as an online reference you can bookmark and print from your browser. Downloadable versions may be added later.

Check them against official documentation such as MDN Web Docs, the WordPress developer handbook and Google Search Central.

Start with the HTML and CSS sheets, then JavaScript. They cover the building blocks used on every website.

Next step

Keep building your skills

Explore the rest of our Resources guides, or follow the beginner path step by step.