CSS margin-bottom Property
The CSS margin-bottom property is used to specify the amount of margin to be used on the bottom of an element. The margin can be set in terms of length or percentage.
Syntax:
margin-bottom: <length> | <percentage> | auto
Property values:
-
Length: This value specifies the length of margin with a fixed value. This value can be positive, negative or zero.
Example:
<!DOCTYPE html><html><head><title>CSS margin-bottom</title><style>div{background-color: lightgreen;}</style></head><body><h1style="color: green">GeeksforGeeks</h1><!-- margin-bottom for below divis set to 50px --><divstyle="margin-bottom: 50px">Line One</div><!-- margin-bottom for below divis set to 0px --><divstyle="margin-bottom: 0px">Line Two</div><div>Line Three</div></body></html>chevron_rightfilter_noneOutput:
-
Percentage: This value specifies the amount of margin as a percentage relative to the width of the containing element.
Example:
<!DOCTYPE html><html><head><title>CSS margin-bottom</title><style>h1 {color: green;}.larger {width: 300px;background-color: white;}.smaller {width: 100px;background-color: white;}div{background-color: lightgreen;}</style></head><body><h1>GeeksforGeeks</h1><!-- margin-bottom is set to 10% with width ofcontaining box set to 300px --><divclass="larger"><divstyle="margin-bottom: 10%";>Line One</div><div>Line Two</div></div><!-- margin-bottom is set to 10% with width ofcontaining box set to 100px --><divclass="smaller"><divstyle="margin-bottom: 10%;">Line One</div><div>Line Two</div></div></body></html>chevron_rightfilter_noneOutput:
- auto: If the value of this property is set as “auto” then the browser automatically calculates a suitable value for the margin size.
Supported Browsers: The browser supported by margin-bottom property are listed below:
- Google Chrome
- Internet Explorer
- Firefox
- Opera
- Safari
Recommended Posts:
- HTML | DOM Style marginBottom Property
- CSS | transition-property Property
- CSS | nav-up property
- CSS | right Property
- CSS | nav-down property
- CSS | top Property
- CSS | nav-right property
- CSS | all Property
- CSS | animation-name Property
- CSS | perspective Property
- CSS | transform Property
- CSS | visibility Property
- HTML | DOM li value Property
- CSS | nav-index property
- CSS | filter Property
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



