by DannyUpdated 9 sections

Everything here works in current evergreen browsers.

Download the PDF

Selectors


_10
.card > p { } /* direct child */
_10
.card p { } /* any descendant */
_10
h2 + p { } /* next sibling */
_10
a:hover, a:focus-visible { }
_10
li:nth-child(odd) { }
_10
input:not([disabled]) { }
_10
.card:has(img) { } /* parent that contains */
_10
:is(h1, h2, h3) { } /* any of these */

Box model


_10
*, *::before, *::after { box-sizing: border-box; }
_10
.box {
_10
margin: 1rem auto; /* centre a block */
_10
padding: 1rem 2rem; /* y x */
_10
border: 2px solid;
_10
inline-size: min(100%, 60ch);
_10
}

Flexbox


_10
.row {
_10
display: flex;
_10
gap: 1rem;
_10
justify-content: space-between; /* main axis */
_10
align-items: center; /* cross axis */
_10
flex-wrap: wrap;
_10
}
_10
.grow { flex: 1; } /* take spare space */
_10
.fixed { flex: none; } /* don't shrink */

Grid


_11
.grid {
_11
display: grid;
_11
grid-template-columns: repeat(3, 1fr);
_11
gap: 2rem;
_11
}
_11
.auto {
_11
grid-template-columns:
_11
repeat(auto-fill, minmax(200px, 1fr));
_11
}
_11
.wide { grid-column: span 2; }
_11
.centre { display: grid; place-items: center; }

Positioning


_10
.parent { position: relative; }
_10
.badge { position: absolute; inset: 0 0 auto auto; }
_10
.header { position: sticky; top: 0; }
_10
.modal { position: fixed; inset: 0; }
_10
.on-top { z-index: 10; } /* needs position */

Units

UnitRelative to
remRoot font size
emElement's font size
%Parent size
vw / vhViewport
dvhViewport minus browser UI
chWidth of "0"

Responsive


_10
@media (width >= 768px) { .nav { display: flex; } }
_10
_10
.card-list { container-type: inline-size; }
_10
@container (width > 400px) {
_10
.card { flex-direction: row; }
_10
}
_10
_10
h1 { font-size: clamp(2rem, 5vw, 4rem); }

Custom properties


_10
:root { --brand: #4338ca; --space: 1rem; }
_10
.button {
_10
background: var(--brand);
_10
padding: var(--space, 8px); /* fallback */
_10
}

Transitions


_10
.button { transition: transform 0.2s ease; }
_10
.button:hover { transform: scale(1.05); }
_10
_10
@keyframes spin { to { rotate: 360deg; } }
_10
.loader { animation: spin 1s linear infinite; }
_10
_10
@media (prefers-reduced-motion: reduce) {
_10
* { animation: none; transition: none; }
_10
}