Here is image to explain my question better
Every control has bounding box and every control has margins and padding. In the image The Gap between button border and the border of the bounding box is labeled as GAP-B, is this the padding or Margin?
Also there is gap between the two buttons GAP-A, is this the padding or margin?
What is the Difference Between Margin and Padding. The main difference between margin and padding is that margin helps to create space around the element outside the border, while padding helps to create space around the element inside the border.
Padding is the space inside the border of a block that separates the border from the content. The margin is the spacing outside the border that separates a block from the adjacent blocks.
It is not possible to assign negative values for those properties. The main difference between margin and padding is that margin helps to create space around the element outside the border, while padding helps to create space around the element inside the border.
Another part of the CSS box model, padding is the space between a border and the element within it. Padding surrounds the text or image within a certain boundary to prevent that content from touching the border, or box, around it. Like margins, you can create and change the amount of padding when designing a webpage.
Gap A is Margin and Gap B is Padding.
Padding on second Border
<StackPanel>
<Border Height="100" Width="400" >
<Button Content="StackOverFlow" Background="Yellow"/>
</Border>
<Border Padding="20" Background="Lime" Height="100" Width="400">
<Button Content="StackOverFlow" Background="Yellow"/>
</Border>
</StackPanel>
Margin on second border
<StackPanel>
<Border Height="100" Width="400" >
<Button Content="StackOverFlow" Background="Yellow"/>
</Border>
<Border Margin="20" Background="Lime" Height="100" Width="400">
<Button Content="StackOverFlow" Background="Yellow"/>
</Border>
</StackPanel>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With