HTML, CSS & JavaScript Cheat Sheet
Quick reference for semantic HTML5 tags, accessible forms, CSS Box Model, Flexbox, Grid, variables, ES6 array methods, DOM events, localStorage, and Fetch API.
1 min readUpdated 2026-11-30
Semantic HTML5 & Accessible Forms
html
<header><nav>...</nav></header>
<main>
<section aria-labelledby="signup-title">
<h1 id="signup-title">Join Free</h1>
<form>
<label for="email">Email</label>
<input id="email" type="email" required />
<button type="submit">Continue</button>
</form>
</section>
</main>
<footer>...</footer>CSS Box Model, Variables & Responsive Layout
css
* {
box-sizing: border-box;
}
:root {
--brand: #4f46e5;
--surface: #ffffff;
}
/* Centered navbar with Flexbox */
.row {
display: flex;
align-items: center;
justify-content: space-between;
gap: 1rem;
flex-wrap: wrap;
}
/* Auto-responsive cards with CSS Grid */
.grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
gap: 1.5rem;
}Modern ES6 Arrays & Objects
javascript
const courses = [
{ title: "HTML/CSS", hours: 10, free: true },
{ title: "SQL", hours: 12, free: true },
];
const titles = courses.filter((c) => c.free).map((c) => c.title);
const totalHours = courses.reduce((sum, c) => sum + c.hours, 0);
const { title, hours } = courses[0];JavaScript DOM Events & localStorage
javascript
const form = document.querySelector("#task-form");
const input = document.querySelector("#task-input");
form.addEventListener("submit", (e) => {
e.preventDefault();
const text = input.value.trim();
if (!text) return;
localStorage.setItem("tasks", JSON.stringify([{ text, done: false }]));
});Fetch API (async / await + Error Check)
javascript
async function getJson(url) {
const res = await fetch(url);
if (!res.ok) throw new Error(`HTTP ${res.status}`);
return res.json();
}