How the CSS is produced
Eight number fields take the four margin sides and the four padding sides, each from 0 to 200 pixels, plus border width to 40 and border radius to 100. A Match all button in each group copies that group's top value across the other three sides. The output runs a .box shorthand rule first, then repeats every side as longhand margin and padding.
A worked example
Defaults are margin 16 on all sides and padding 12 top and bottom with 20 left and right, border 2, radius 8. The shorthand test collapses margin to the single value 16px, and because top equals bottom and right equals left, padding becomes the two-value form 12px 20px. The rule reads margin: 16px; padding: 12px 20px; border: 2px solid #f59e0b; border-radius: 8px. Change only the top padding to 24 and padding prints the three-value form 24px 20px 12px, since the horizontal sides still match.
The shorthand collapsing rules
Four values are printed only when no symmetry exists: all-equal gives one value, top-with-bottom and right-with-left gives two, and right matching left alone gives three. A zero border or radius drops its line, but margin and padding lines always appear, even when zero.
Where it stops
- Only whole pixel values exist; the field parser reads an integer, and negative or blank entries are clamped to zero, so margin auto centring and percentage padding cannot be produced.
- The border colour is hard-coded to the amber used in the preview and must be edited by hand.
- The longhand section covers margin and padding only; border and radius appear just once, in the shorthand block.
- box-sizing is not emitted, so padding still adds to element width under the default content-box model.
Questions people ask
Why does the preview border look rounder than the number?
The nested preview boxes add the border width to the radius before painting, so each outer layer keeps the content corners visually consistent; the CSS itself writes the plain figure.
Why print longhands as well as the shorthand?
Both describe the same box; the longhand block is there for stylesheets that edit one side at a time.
Finish the box with the box shadow generator, round individual corners in the border radius generator, and run the combined stylesheet through the CSS validator.