Style marginBottom property
- Previous Page margin
- Next Page marginLeft
- Go to Parent Level HTML DOM Style Object
Definition and Usage
marginBottom
property sets or returns the bottom outer margin of the element.
margin property and padding property All insert space around the element. However, the difference is that margin inserts space around the border, while padding inserts space inside the element's border.
See also:
CSS Tutorial:CSS Margin
CSS Reference Manual:margin-bottom property
HTML DOM Reference Manual:margin property
Instance
Example 1
Set the bottom outer margin of the <div> element:
document.getElementById("myDiv").style.marginBottom = "50px";
Example 2
Reset the bottom outer margin of the <div> element to "normal":
document.getElementById("myDiv").style.marginBottom = "0px";
Example 3
Returns the bottom outer margin of the <div> element:
alert(document.getElementById("myDiv").style.marginBottom);
Example 4
Difference between marginBottom and paddingBottom:
function changeMargin() { document.getElementById("myDiv").style.marginBottom = "100px"; } function changePadding() { document.getElementById("myDiv2").style.paddingBottom = "100px"; }
Syntax
Return marginBottom property:
object.style.marginBottom
Set marginBottom property:
object.style.marginBottom = "%|length|auto|initial|inherit"
Property Value
Value | Description |
---|---|
% | Defines the bottom outer margin as a percentage of the parent element's width. |
length | Defines the bottom outer margin with a length unit. |
auto | browser settings for the bottom outer margin. |
initial | Sets this property to its default value. See initial. |
inherit | Inherits this property from its parent element. See inherit. |
Technical Details
Default value: | 0 |
---|---|
Return value: | A string representing the element's bottom outer margin. |
CSS Version: | CSS1 |
Browser Support
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support |
- Previous Page margin
- Next Page marginLeft
- Go to Parent Level HTML DOM Style Object