Margin
A CSS property that adds space outside an element's border, between it and surrounding elements. Unlike padding, margin is outside the element's background.
Understanding Margin in HTML & CSS
What it does: margin: 20px adds 20px of space outside the paragraph's border on all four sides, pushing surrounding elements away. margin-top and margin-bottom set only their respective sides. The left and right margins remain at their default value. auto splits the remaining horizontal space equally on both sides, centering the element. The element must have a fixed width. The margin shorthand accepts 1, 2, 3 or 4 values. Five values is invalid and will be ignored by the browser. Unlike padding, margin can be negative. Negative margins pull an element closer to or overlapping its neighbours. The colon is required in CSS between the property name and its value. Without it, the declaration is invalid.
Common mistakes: CSS declarations require a colon. It should be margin: 10px; not margin 10px;. The margin shorthand accepts 1, 2, 3 or 4 values — not 5. Five values is invalid CSS.
Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.
This module's key terms are also in a printable crossword (Modules 43–52) and word search (Modules 43–63).
Take this worksheet further — free with Cloodit
Each concept is reinforced from every angle — learned, then applied, then tested.
Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.
Over 100 of them, across seven natural biomes.
Turns their work into revision material ready for Flash Cards and Exam study.
Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.
Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.
Quick Questions
Match the Pairs
Key Term
marginFill in the Blanks
Spot the Error
Student with a class code? Join your class →