What is the difference between Margin and Padding?
Short answer
Padding is space inside an element between its border and its content; it is a property of layouts and some views. Margin is space outside an element between it and its neighbors; it applies to any View.
Advertisement
AModel answer
Padding is space inside an element between its border and its content; it is a property of layouts and some views. Margin is space outside an element between it and its neighbors; it applies to any View. Both accept a Thickness (uniform, horizontal/vertical, or left/top/right/bottom).
<Frame Padding="16" Margin="8,12">
<Label Text="Card content" />
</Frame>Real-world example
A card gets breathing room from surrounding cards via Margin while its text is inset from the card edge via Padding.
Likely follow-ups
- What is a Thickness? | Which elements support Padding?
Related topics