Margin is the spacing outside an element.
The margin-bottom
property specifies the bottom margin of an element.
An element with a 50-pixel margin-bottom
.
<div style="margin-bottom: 50px; background: aliceblue;">
An element with a 50px bottom margin
</div>
The margin-bottom
property accepts any length value, such as, px
, %
, em
, etc.
Margin values can be positive or negative.
margin-bottom: length | auto | initial | inherit;
Value | Description |
---|---|
length | Sets the bottom margin using any CSS length value. Negative values are allowed. |
% | Sets bottom margin in percent. |
auto | Browser calculates a bottom margin. |
initial | Sets the value to its default value. |
inherit | Inherits the value from its parent element. |
Click the buttons to see the different margin-bottom
values.
<style>
.margin-example {
background: aliceblue;
margin-bottom: 5%;
padding: 10px;
}
</style>
<div class="margin-example">
margin-bottom: 5%
</div>
This table shows when margin-bottom
support started for each browser.
Chrome
|
1.0 | Dec 2008 |
Firefox
|
1.0 | Nov 2004 |
IE/Edge
|
6.0 | Aug 2001 |
Opera
|
3.5 | Nov 1998 |
Safari
|
1.0 | Jun 2003 |