asp.net.ph

Skip Navigation Links

margin-bottom Attribute | marginBottom Property

CSS Attributes Index   Box Attributes


Sets or retrieves the height of the bottom margin for the object.

Syntax


CSS { margin-bottom: [ length | percentage | 'auto' ] }
Script object.style.marginBottom = [ length | percentage | 'auto' ]

Possible Values


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.

Remarks

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.

Example

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 

See Also

paddingBottom, CSS Length Units



© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note