CSS Attributes Index Box Attributes
Sets or retrieves the height of the bottom margin for the object.
CSS |
{ margin-bottom: [ length | percentage | 'auto' ] } |
Script |
object.style.marginBottom = [ length | percentage | 'auto' ] |
length |
Floating-point number and a valid CSS length unit: either an absolute units designator ( cm, mm, in, pt, pc, or px ) or a relative units designator ( em or ex ). |
percentage |
Value expressed as a percentage of the parent object’s height. |
auto |
Value set to equal the value of the opposite side. |
The property is read/write with a default value of 0; this attribute is not inherited.
Negative margins are supported except for top and bottom margins on inline objects.
The width property must be set on a SPAN object for the margin properties to render.
Possible length values specified in a relative measurement using the height of the element’s font ( em ) or the height of the letter "x" ( ex ) are supported as of Microsoft® Internet Explorer® 4.0 or later.
The following examples demonstrate use of inline event handlers to dynamically set the bottom margin of an element. Both methods yield the same effect.
The sample below defines margin-bottom style attributes in an embedded stylesheet, and invokes calls to the stylesheet in response to mouse events.
<style>
.widebott { margin-bottom: 2cm }
</style>
...
<p onclick="this.className='widebott'" ondblclick="this.className=''">
...
</p>
Show me
The sample below uses inline event handlers to dynamically set an object’s bottom margin in response to mouse events.
<p onclick="this.style.marginBottom='2cm'"
ondblclick="this.style.marginBottom=''">
...
</p>
Show me
paddingBottom, CSS Length Units