marginBottom Property - Javascript CSS Style Property

Javascript examples for CSS Style Property:marginBottom

Description

The marginBottom property sets or gets the bottom margin.

Property Values

Value Description
% bottom margin in percentage of the width of the parent element
length bottom margin in length units
autoThe browser sets the bottom margin
initial Sets this property to its default value.
inherit Inherits this property from its parent element.

Technical Details

Item Value
Default Value: 0
Return Value: A String, representing the bottom margin of an element
CSS VersionCSS1

Set the bottom margin of a <div> element:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<style>
#myDiv {//  w  w  w  .  j  av  a 2s  . c  o m
    border: 1px solid #FF0000;
}
</style>
</head>
<body>

<div id="myDiv" style="margin-bottom:5cm;">This is a div.</div>
<br>
<button type="button" onclick="myFunction()">Return bottom margin</button>

<script>
function myFunction() {
    document.getElementById("myDiv").style.marginBottom = '10px';
}
</script>

</body>
</html>

Related Tutorials