CSS Shorthand Generator
Build the shortest margin, padding, border, font, flex, transition, animation, background, outline, inset and grid-area shorthands — or paste a shorthand and expand it back to longhand.
Shorthand
Longhand
Preview
Longhand
How to use the CSS shorthand generator
- In Build shorthand, choose a property and fill in the parts you care about — the tool collapses the values to the shortest legal shorthand and shows the longhand it stands for.
- Watch the note under the result: it explains why four sides became one, two or three values.
- Switch to Expand shorthand, paste declarations you found in someone else's CSS, and read them back as explicit longhand properties.
FAQ
Why does my font shorthand break things?
font resets every font longhand it does not mention, including line-height, font-variant and font-stretch. Use it only when you are setting the whole font, otherwise set longhands.
What order do the four box values go in?
Clockwise from the top: top, right, bottom, left. With three values the missing left copies right; with two, top/bottom then left/right; with one, all four.
Is shorthand always better?
Not always. Shorthands reset the properties they omit, which is exactly what you want for a fresh component and exactly what bites you when you are overriding one value in a theme. For an override, prefer the longhand.