CSS Margin Shorthand
Predict Output Easy
Question
What are the four margin values (top right bottom left)?
Code
/* margin: 10px 20px 30px 40px; */
Hint
The order is top, right, bottom, left (clockwise).
Explanation
The margin shorthand with four values follows clockwise order: top, right, bottom, left. So margin: 10px 20px 30px 40px means top=10px, right=20px, bottom=30px, left=40px. With two values (10px 20px), it is top/bottom=10px, left/right=20px. With one value, all sides are the same.
Related Resources
Related Lessons
- CSS Box Model
Learn the CSS box model.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.