Margin
Margin is the space outside an element’s border in the CSS box model.
Margins separate boxes from neighboring content. Vertical margins in normal block flow can collapse under specific conditions, which differs from padding behavior.
Space outside the border
Margins separate boxes from neighboring content. Vertical margins in normal block flow can collapse under specific conditions, which differs from padding behavior. In practical terms, Margin belongs to the presentation and layout layer. Knowing that layer is important because it tells you what the term can change, what it cannot change, and where to look when something behaves unexpectedly.
Separating neighboring boxes
margin: 24px 0 creates external vertical space around an element without enlarging its background area.
Where margins collapse or combine
You do not need to memorize the term in isolation. It becomes useful when you can recognize it in the tool, browser, file or conversation where the concept is doing real work.
Margin and padding create different kinds of space
Margin is the space outside an element’s border in the CSS box model. By contrast, Padding is the space between an element’s content and its border. The two can appear in the same project, but they describe different parts of the work and should not be used as interchangeable labels.
The mistake: using margin to fake internal spacing
The common mistake is to use Margin as if it also meant Padding. That blurs two separate decisions and usually sends troubleshooting in the wrong direction. A better test is practical: If spacing behaves strangely, check margin collapsing and whether gap or padding better expresses the relationship.
Why outside spacing affects relationships
In day-to-day work, Margin matters when the concept needs to be identified precisely instead of being grouped with a nearby term. The practical value is not the vocabulary itself; it is being able to identify the right control, file, setting or decision when the concept becomes relevant.
margin: 24px 0 creates external vertical space around an element without enlarging its background area. That example is useful because it turns the definition into something you can recognize, test and discuss with other people working on the same project.
Related terms worth learning next
Sources and further reading
Use these references when you need documentation-level detail, specifications or product-specific behavior beyond the plain-English explanation above.