Cheatsheets CSS Cheatsheet Use this CSS cheatsheet for fast reminders on selectors, flexbox, grid, spacing, radius, shadows, gradients, media queries and responsive styling patterns you can copy into real interfaces.
Quick reference Selectors Class .cardTargets elements with class="card".
ID #mainTargets one element with id="main".
Child .nav > aDirect child selector.
Attribute input[type="email"]Targets elements by attribute.
Layout Flex row display: flex;
Grid display: grid;
Gap gap: 1rem;
Responsive max width: min(100%, 72rem);
Responsive Media query @media (max-width: 768px) { ... }
Fluid type font-size: clamp(1rem, 2vw, 2rem);
Aspect ratio aspect-ratio: 16 / 9;
Container fit max-width: 100%;
.nav {
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
gap: 16px;
}<div class="nav">
<span>Logo</span>
<span>Docs</span>
<strong>Start</strong>
</div>Live preview
Logo Docs Start
.cards {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
grid-template-rows: repeat(2, auto);
gap: 16px;
}<div class="cards">
<article>One</article>
<article>Two</article>
<article>Three</article>
</div>.panel {
padding: 16px;
border-radius: 18px;
}<div class="panel">Content</div>.card {
background: linear-gradient(135deg, #2563eb, #14b8a6);
box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
}<div class="card">
<strong>Gradient card</strong>
<p>Shadow, radius and layered color.</p>
</div>@media (max-width: 640px) {
.cards {
grid-template-columns: 1fr;
gap: 16px;
}
}<div class="cards">
<article>Desktop column</article>
<article>Mobile stack</article>
</div>Live preview
Mobile gap: 16
Desktop: 3 columns Mobile: 1 column
When to use Use flexbox for one-dimensional rows or columns. Use grid when columns and rows both matter. Use media queries when layout needs to change at a breakpoint. Quick tips Start with normal document flow before adding layout rules. Use gap for spacing inside flex and grid containers. Prefer rem, %, min(), max() and clamp() for responsive sizing. Common mistakes Using fixed pixel widths that overflow small screens. Adding margins to every child instead of using gap. Hiding focus styles while styling links and buttons. Best practices Keep layout rules close to the component they affect. Use predictable tokens for spacing, radius and shadows. Test keyboard focus and narrow mobile widths before shipping. Examples .grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
gap: 1rem;
}a:focus-visible,
button:focus-visible {
outline: 3px solid #2563eb;
outline-offset: 3px;
}Common mistakes and tips Use gap for spacing inside flex and grid layouts instead of manual child margins. Avoid fixed widths on mobile; prefer max-width, min(), clamp() and flexible grids. Keep focus-visible styles obvious for keyboard users. CSS FAQ What is included in the CSS cheatsheet? CSS Cheatsheet includes quick reference sections, practical examples, common mistakes, tips and links to related DevKitYard tools.
Is the CSS cheatsheet interactive? Yes. This cheatsheet includes visual examples with copyable code and lightweight controls where interaction helps explain the pattern.
When should I use this CSS reference? Use it when you need to recall syntax, compare common patterns or avoid mistakes without opening a long tutorial.
What should I use after reading this cheatsheet? Use related DevKitYard tools such as CSS Gradient Generator, CSS Beautifier, Flexbox Generator when you need to format, validate, generate or inspect real output.