Code Reference

Glossary

CSS · Reference cheat sheet

Glossary

CSS · Reference cheat sheet


📋 Overview

Alphabetical glossary of core CSS terms for the cascade, box model, layout, selectors, and modern styling features.

🔧 Core concepts

TermDefinition
At-ruleA CSS statement starting with @, such as @media or @keyframes.
Box modelThe content, padding, border, and margin layers that size an element.
CascadeThe algorithm that resolves conflicting declarations by origin, layer, and specificity.
Containing blockThe ancestor box used as the reference for positioned layout.
Container queryA rule that styles an element based on its container’s size, not the viewport.
DeclarationA property–value pair inside a rule, such as color: red.
EmA length relative to the element’s own computed font size.
FlexboxA one-dimensional layout model for aligning items in a row or column.
GridA two-dimensional layout model of rows and columns.
InheritancePassing certain computed values from parent to child elements.
KeyframesNamed animation frames defined with @keyframes.
Logical propertyDirection-relative properties like margin-inline instead of left/right.
Media queryA condition that applies styles based on device or viewport features.
Pseudo-classA selector state such as :hover, :focus, or :nth-child.
Pseudo-elementA selector for generated parts such as ::before or ::after.
RemA length relative to the root element’s font size.
Rule setA selector plus its block of declarations.
SelectorThe pattern that matches which elements a rule applies to.
SpecificityA weight used to decide which competing selector wins.
Stacking contextA local layering scope that controls how z-index paints.
ShorthandA property that sets multiple related longhands at once, like margin.
TransformA visual change such as translate, rotate, scale, or skew.
TransitionSmooth interpolation of property changes over time.
VariableA custom property declared with --name and read via var().
ViewportThe visible area of the page used by units like vw and vh.
Z-indexA stacking order value within a stacking context.

💡 Examples

Flexbox and variables:

:root {
  --gap: 1rem;
}
.row {
  display: flex;
  gap: var(--gap);
  align-items: center;
}

Grid and media query:

.layout {
  display: grid;
  grid-template-columns: 1fr;
}
@media (min-width: 768px) {
  .layout {
    grid-template-columns: 240px 1fr;
  }
}

Specificity and cascade layers:

@layer base, components;
@layer base {
  button { padding: 0.5rem; }
}
@layer components {
  .btn { padding: 1rem; }
}

⚠️ Pitfalls

  • Confusing margin (outside border) with padding (inside border).
  • Mixing flex and grid goals — one axis vs two axes.
  • Treating pseudo-class (:hover) like a pseudo-element (::before).
  • Assuming higher z-index always wins — stacking contexts can trap layers.
  • Equating em and rem — em is relative to the element; rem to the root.

On this page