Back to results for “Controls & Views”
.NET MAUI › XAML & UI Layouts

What is the difference between Margin and Padding?

Intermediate

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.

Common follow-ups: What is a Thickness? | Which elements support Padding?