Utility Empire

CSS - Quick Reference

Selectors, the box model, layout, typography and the effect properties that do the real work in modern CSS. All rows are plain text - search to filter, click Copy to grab the pattern.

Reference rack
STATUSREADY
ROWS56
NETWORKLOCAL
MODEREFERENCE
Item / patternWhat it means / how to use it
*Universal selector - matches every element; powerful but expensive, use sparingly.
elementType selector (p, div, a, section).
.class.btn - class selector, the workhorse of styling.
#idID selector; IDs must be unique, prefer classes for styling.
A BDescendant combinator - any B inside A.
A > BChild combinator - a direct child B of A only.
A + BAdjacent sibling combinator - the first B immediately after A.
A ~ BGeneral sibling combinator - any B that follows A.
[attr="v"]Attribute selector; also ^=, $= and *= for prefix, suffix and substring.
:hover / :focus / :activeInteraction states; always include :focus so keyboard users see focus.
:first-child / :last-child / :nth-child(2n)Positional pseudo-classes for alternating rows and edge cases.
:not(...)Negation - input:not([type="submit"]) matches everything except submits.
:is(...) / :where(...)Forgiving selector lists; :where adds zero specificity for reset-style rules.
:rootThe document root - the classic home for custom properties.
marginSpace outside the border; shorthand takes 1, 2, 3 or 4 values.
paddingSpace inside the border and around the content.
borderShorthand: border-width border-style border-color.
width / heightContent-box dimensions before padding/border unless box-sizing says otherwise.
box-sizing: border-boxWidth and height now include padding and border; the default for grid systems.
max-width: 100%Keeps images and embeds from blowing out their container.
overflowhidden clips, auto adds scrollbars, scroll always shows them.
display: block / inline / inline-blockThe three basic display roles.
display: flexFlexbox: one-dimensional row or column layout.
flex-direction / justify-content / align-itemsFlex main-axis direction and alignment on both axes.
flex: 1Grow-and-shrink shorthand; distributes leftover space evenly across siblings.
display: gridTwo-dimensional layout with rows and columns.
grid-template-columns: repeat(3, 1fr)Defines columns; 1fr is an equal fraction of free space.
gapSpace between grid or flex items; the shorthand for row-gap and column-gap.
position: relativePositioned, offset relative to its normal flow spot.
position: absolutePositioned relative to the nearest positioned ancestor.
position: fixedPositioned relative to the viewport - sticky navbars and FABs.
position: stickyScrolls normally until a threshold, then sticks.
top / right / bottom / left + z-indexOffsets from a positioned ancestor; z-index controls stacking order.
font-familyFont stack: a comma-separated list of fallbacks; quote names with spaces.
font-size / font-weight / font-styleSize, thickness (400 normal / 700 bold) and italics.
line-heightLine spacing; use a unitless value (1.5) that scales with the font size.
letter-spacing / text-transformTracking; and uppercase / lowercase / capitalize.
text-alignleft, right, center or justify.
text-decorationunderline / line-through; remove link underlines with none.
text-overflow: ellipsisTruncates with ... but needs white-space: nowrap and overflow: hidden.
colorForeground text color.
backgroundShorthand: color, image, position, repeat, size.
opacity0 to 1 transparency of the whole element.
transitionAnimate property changes: transition: all .2s ease.
transformrotate / scale / translate / skew; cheap to animate, no main-thread layout.
animation + @keyframesDeclared keyframe sequences: name duration iteration.
box-shadowx y blur spread color; prefix with inset for an inner shadow.
:root { --tone: #4338CA } + var(--tone)Custom properties: they inherit, cascade, and can change in media queries or from JS.
@media (max-width: 768px)Responsive breakpoint rulesets.
@importPulls in another stylesheet - render-blocking, prefer a <link> tag.
!importantEscalates specificity; avoid except as a last resort.
cursor: pointerHand cursor on interactive elements.
object-fit: coverFills a box without distortion, cropping the overflow (images, video).
aspect-ratioDeclares a width/height ratio such as 1 / 1 or 16 / 9 for responsive media.
clamp(min, pre, max)Fluid value that scales between bounds, great for font-size.
insetShorthand for top / right / bottom / left.