CSS Property: margin-bottom
[this page | pdf | back links]
The CSS (CSS1) margin-bottom property sets the width of
the bottom margin of an element.
Valid property values
(other than inherit
and initial) are:
Value
|
Description
|
length
|
Any specified margin
size as a CSS length
|
%
|
Margin specified as
percentage of width of container
|
auto
|
Browser calculates
margin
|
Default Value:
|
0
|
JavaScript syntax:
|
e.g. object.style.marginBottom="30px"
|
Inherited:
|
No
|
Animatable:
|
Yes
|
EXAMPLE:
HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head>
<style>
div {border: 2px solid red; width: 300px}
p {border: 2px solid green; width: 200px}
p.x1 {margin-bottom: 50px;}
</style>
</head>
<body>
Element with default property<br>
<div>a<p>1</p>b</div><br><br>
Property set using in-file HTML style<br>
<div>a<p class="x1">2</p>b</div><br><br>
Property set using JavaScript<br>
<div>a<p id="x2">3</p>b</div>
<script>
document.getElementById("x2").style.marginBottom = "50px";
</script>
</body>
</html>
|
FUNCTION THAT MAY ASSIST IN TESTING WHETHER FEATURE IS SUPPORTED:
function isSupportedCSSPropertyMarginBottom() {
var x = document.createElement("DIV"); x.style.marginBottom = "50px"; return (window.getComputedStyle(x, null).marginBottom == "50px");
} |
NAVIGATION LINKS
Contents | Prev | Next | CSS Properties