CSS illustration has no single prescribed method — everyone works on the same canvas, and there is often more than one route to the same pixels. What follows is a set of techniques that can shorten the path from blank page to finished drawing.

Expect time and tinkering

The first thing to internalize is that accuracy and complexity cost time. The slow part is rarely choosing properties; it is tinkering until shapes look right. Get very familiar with the styles inspector in your browser dev tools, and consider VisBug as a supplementary tool. Both Ben Evans and Diana Smith have discussed the time involved in their CSS illustration work. One telling exchange on a simple CSS cup illustration produced this reply:

I was tempted to create this in CSS when I first saw the tweet but then thought my reply would take about a month.

Trace a reference image

The core problem is rendering an existing image with the DOM and CSS, not designing on the fly. A reliable technique, though apparently not common knowledge, is to trace the image directly in the browser:

  1. Find or create an image of what you want to illustrate.
  2. Pull it into your HTML with an <img> tag.
  3. Position it in a way that it will sit underneath your illustration.
  4. Reduce the image opacity so that it's still visible but not too overpowering.
  5. Trace it with the DOM.

Make it responsive by scaling your own unit

If a CSS illustration collapses on a small screen, a visitor may see only part of it — and miss the best of the demo. The fix is to leverage viewport units for your illustrations and create your own scaled unit. Scaled units or percentages both work for sizing and positioning; the scaled unit matters especially for box shadows, since box-shadow accepts viewport units but not percentages.

With an <img> reference in place, sizing it at a height of 50vmin (the desired size of the illustration) and reducing its opacity gives a clear tracing guide.

<image src='egghead.png'/>
img {
  height: 50vmin;
  left: 50%;
  opacity: 0.25;
  position: fixed;
  top: 50%;
  transform: translate(-50%, -50%);
}

Derive a fractional unit from the largest dimension — here, the height — and use calc() to size the illustration's container. Styling the internal elements with percentages or that --unit custom property keeps the whole piece proportional, with 50vmin as the sizing constraint, for only a few lines of math.

/**
  * image dimensions are 742 x 769
  * width is 742
  * height is 769
  * my desired size is 50vmin
*/
:root {
  --size: 50;
  --unit: calc((var(--size) / 769) * 1vmin);
}
--unit: 0.06501950585vmin;
.egg {
  height: calc(769 * var(--unit));
  position: relative;
  width: calc(742 * var(--unit));
  z-index: 2;
}

Measure real objects

When working from a physical object, actual measurements improve fidelity — a tape measure is legitimate equipment. Say the scene is a TV combo unit; expressing dimensions in centimeters and using the television's real height as the base for a responsive unit works well. Custom properties let each value carry a meaningful name.

:root {
  --light-switch: 15;
  --light-switch-border: 10;
  --light-switch-top: 15;
  --light-switch-bottom: 25;
  --tv-bezel: 15;
  --tv-unit-bezel: 4;
  --desired-height: 25vmin;
  --one-cm: calc(var(--desired-height) / var(--tv-height));
  --tv-width: 158.1;
  --tv-height: 89.4;
  --unit-height: 42;
  --unit-width: 180;
  --unit-top: 78.7;
  --tv-bottom: 114.3;
  --scaled-tv-width: calc(var(--tv-width) * var(--one-cm));
  --scaled-tv-height: calc(var(--tv-height) * var(--one-cm));
  --scaled-unit-width: calc(var(--unit-width) * var(--one-cm));
  --scaled-unit-height: calc(var(--unit-height) * var(--one-cm));
}

In the example, the TV is 158.1cm wide and 89.4cm tall (per the manual), but on the page it always scales to 25vmin.

Position absolutely, structure carefully

Most elements in an illustration end up absolutely positioned, so set a blanket rule to save keystrokes:

/* Your class name may vary */
.css-illustration *,
.css-illustration *:after,
.css-illustration *:before,
.css-illustration:after,
.css-illustration:before {
  box-sizing: border-box;
  position: absolute;
}

Beyond placement, avoid a flat DOM. Keeping the structure atomic — separate elements for arms, feet, head in a CSS Snorlax study — makes parts easy to move, show and hide, and animate; applying an animation to a single class such as .snorlax__arm-left is far easier than animating merged markup.

Adopt an approach and stick to it, even though this is difficult early on. Modelling the work on a layered vector image helps: build from the bottom up, large shapes first and fine details later. Sketching on paper can clarify the split, and stacking order can be adjusted as you go.

Shapes: clip-path, border-radius, and awkward corners

Curves come from border-radius, and one underused form is the “double” syntax, which lets each corner take a horizontal and a vertical radius. Percentages are advisable throughout for responsiveness.

Complex shapes usually call for clip-path, particularly to cut off parts of elements when hiding a parent's overflow won't do. For a long outer curve, one tactic is a large element with border-radius set and overflow: hidden on the body, so only the needed arc remains — a toggle in an example reveals the element cutting the corner. A transparent element with a thick border plus a radius (clipping any excess) is another option. Overlaying a circle that matches the background is possible but harder to maintain if the background color later changes, unless the color is stored in a variable.

Shading: stacked gradients and shadows

When layout and color are settled and the image still looks wrong, missing shading is usually the cause — shading gives depth and realism. These effects typically combine box-shadow with background-image, and both accept comma-separated stacks. A cauldron in one demo carries multiple gradients across its body:

.cauldron {
  background:
    radial-gradient(25% 25% at 25% 55%, var(--rim-color), transparent),
    radial-gradient(100% 100% at -2% 50%, transparent, transparent 92%, var(--cauldron-color)),
    radial-gradient(100% 100% at -5% 50%, transparent, transparent 80%, var(--darkness)),
    linear-gradient(310deg, var(--inner-rim-color) 25%, transparent), var(--cauldron-color);
}

radial-gradient() and linear-gradient() are both in play there, and not always with tidy round values — expect to spend real time tweaking numbers in the style inspector. The same stacking applies to box-shadow, where inset adds tricky borders and depth:

.cauldron__opening {
  box-shadow:
    0 0px calc(var(--size) * 0.05px) calc(var(--size) * 0.005px) var(--rim-color) inset,
    0 calc(var(--size) * 0.025px) 0 calc(var(--size) * 0.025px) var(--inner-rim-color) inset,
    0 10px 20px 0px var(--darkness), 0 10px 20px -10px var(--inner-rim-color);
}

Sometimes filter: drop-shadow() produces the desired effect instead. Lynn Fisher's a.singlediv.com is a strong place to inspect these properties in practice; box-shadow alone can even carry an entire illustration, as in a single-div dollar shown here and taken further in a box-shadow-based generator by Alvaro Montoro.

Use preprocessors for DRY markup

Preprocessors keep illustration code tidy without being required. Pug speeds up HTML, notably with loops for repeated elements, and CSS custom properties can be scoped so styles are defined once and overridden where needed. Repeating flowers built from identical markup can each get an index class that applies its own scoped properties — for the first flower:

.flower--1 {
  --hue: 190;
  --x: 0;
  --y: 0;
  --size: 125;
  --r: 0;
}

Every other flower builds on that base. Moving the second one right and up slightly is just different values on the same properties:

.flower--2 {
  --hue: 320;
  --x: 140;
  --y: -75;
  --size: 75;
  --r: 40;
}

All of this is learned through trial and error; what works for one illustrator may differ from what works for another, and those differences are themselves instructive.