Irbisa · Cheatsheet
HTML & CSS
Semantic HTML, the box model, display and positioning, units, Flexbox and Grid, margin collapse, responsive design and container queries, custom properties and theming, CSS Modules, Tailwind and CSS-in-JS
What is semantic HTML, and why use
<nav>,<main>,<article>or<button>instead of a<div>?<body> <header> <nav aria-label="Main"> <a href="/">Home</a> <a href="/pricing">Pricing</a> </nav>…What is the CSS box model, and how wide is
.cardon screen with and withoutbox-sizing: border-box?.card { width: 300px; padding: 20px; border: 2px solid #ccc; margin: 16px;} .card.border-box { box-sizing: border-box;}What is the difference between block, inline and inline-block elements?
What is the difference between
display: none,visibility: hiddenandopacity: 0?/* Hidden on screen, still read by screen readers */.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px;…How do
static,relative,absolute,fixedandstickypositioning differ, and what is an absolute element positioned against?.avatar { position: relative; /* the badge is placed against this box */}.avatar .badge { position: absolute; top: -4px;…What is the difference between
px,em,rem,%,vhanddvh, and which do you use for font sizes?How do you center an element horizontally and vertically, and which way would you pick today?
/* Both axes, any child size */.center-grid { display: grid; place-items: center; min-height: 100dvh;}…What is the difference between pseudo-classes and pseudo-elements, and what does
:has()make possible?/* pseudo-element: a tooltip arrow that is not in the DOM */.tooltip::after { content: ""; position: absolute; top: 100%; left: 16px;…What is margin collapsing, and what is a block formatting context?
.card { background: white;}.card h2 { margin-top: 24px; /* escapes: the card itself moves down 24px */}…What do
flex-grow,flex-shrinkandflex-basisdo, and what doesflex: 1actually mean?.row { display: flex; gap: 8px;} /* equal columns whatever their content */…Find the bug: the long file name in a flex row does not truncate with an ellipsis and pushes the buttons off screen.
/* <li class="file-row"> <div class="info"><p class="name">quarterly-report-final-v2.pdf</p><p>2.4 MB</p></div> <button>Rename</button> <button>Delete</button> </li> */.file-row { display: flex; gap: 8px;}.info { flex: 1;}.name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis;}How do
fr,minmax()andrepeat()size CSS Grid tracks, and what is the difference betweenauto-fillandauto-fit?.page { display: grid; grid-template-columns: 240px minmax(0, 1fr); grid-template-areas: "header header" "nav main";…What are CSS custom properties, how do they differ from Sass variables, and how do you build light and dark themes with them?
:root { --surface: #ffffff; --text: #111827; --accent: #2563eb; color-scheme: light;}…How do you build a responsive layout with mobile-first media queries, and when do container queries fit better?
/* base: one column for phones */.layout { display: grid; gap: 16px;}…How do
srcset,sizesand<picture>serve the right image, and how do you stop images from shifting the layout?<picture> <source type="image/avif" srcset="/img/hero-800.avif 800w, /img/hero-1600.avif 1600w" sizes="100vw" /> <img src="/img/hero-1600.jpg" srcset="/img/hero-800.jpg 800w, /img/hero-1600.jpg 1600w" sizes="100vw"…What is the difference between a CSS
transitionand a@keyframesanimation, and which properties can you animate smoothly?.menu { opacity: 0; transform: translateY(-8px); visibility: hidden; transition: opacity 150ms ease-out, transform 150ms ease-out, visibility 150ms;}…How do you scope styles in a React app: BEM, CSS Modules, Tailwind or CSS-in-JS, and what does each cost?
import styles from './Button.module.css'; // .button, .primary and .bar inside interface ButtonProps { primary?: boolean; children: React.ReactNode;}…What does runtime CSS-in-JS such as styled-components or Emotion cost, and why do Server Components push teams toward zero-runtime styling?
// before: Title.tsx, styles built at runtime from a propconst Title = styled.h1<{ $accent: string }>` font-size: 2rem; color: ${(p) => p.$accent};`;…