mozilla

Revision 494269 of margin-bottom

  • Revision slug: Web/CSS/margin-bottom
  • Revision title: margin-bottom
  • Revision id: 494269
  • Created:
  • Creator: kscarfone
  • Is current revision? No
  • Comment Updated tags

Revision Content

{{CSSRef()}}

Summary

The effect of the CSS margin-bottom property on the element boxThe margin-bottom CSS property of an element sets the margin space required on the bottom of an element. A negative value is also allowed.

This property has no effect on non-replaced inline elements, like {{HTMLElement("tt")}} or {{HTMLElement("span")}}.

{{cssbox("margin-bottom")}}

Syntax

Formal syntax: {{csssyntax("margin-bottom")}}
margin-bottom: 10px;        /* An absolute length */
margin-bottom: 1em;         /* A length relative to the text size */
margin-bottom: 5%;          /* A margin relative to the nearest block container's width */
margin-bottom: auto;

margin-bottom: inherit;

Values

<length>
Specifies a fixed width. See {{xref_csslength()}} for possible values.
<percentage>
A {{xref_csspercentage()}} always relative to the width of the containing block.
auto
See {{cssxref("margin")}}.

Examples

.content { margin-bottom:   5%; }
.sidebox { margin-bottom: 10px; }
.logo    { margin-bottom: -5px; }
#header  { margin-bottom:  1em; }
{{JSFiddleLink("V3hrF")}}

Specifications

Specification Status Comment
{{SpecName('CSS3 Box', '#the-margin', 'margin-bottom')}} {{Spec2('CSS3 Box')}} No significant change.
{{SpecName('CSS3 Transitions', '#animatable-css', 'margin-bottom')}} {{Spec2('CSS3 Transitions')}} Defines margin-bottom as animatable.
{{SpecName('CSS2.1', 'box.html#margin-properties', 'margin-bottom')}} {{Spec2('CSS2.1')}} Removes its effect on inline elements.
{{SpecName('CSS1', '#margin-bottom', 'margin-bottom')}} {{Spec2('CSS1')}} Initial definition.

Browser compatibility

{{CompatibilityTable()}}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support 1.0 {{CompatGeckoDesktop("1")}} 3.0 3.5 1.0 (85)
auto value 1.0 {{CompatGeckoDesktop("1")}} 6.0 (strict mode) 3.5 1.0 (85)
Feature Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support 1.0 {{CompatGeckoMobile("1")}} 6.0 6.0 1.0

See also

  • {{CSS_Reference:Margin()}}

Revision Source

<div>
 {{CSSRef()}}</div>
<h2 id="Summary" name="Summary">Summary</h2>
<p><img alt="The effect of the CSS margin-bottom property on the element box" src="/files/4045/margin-bottom.svg" style="width: 400px; height: 130px; border: 1px solid; margin-right: 1em; margin-bottom: 1em; padding-right: 0.5em; float: left;" />The <code>margin-bottom</code> <a href="/en-US/docs/CSS" title="CSS">CSS</a> property of an element sets the margin space required on the bottom of an element. A negative value is also allowed.</p>
<p>This property has no effect on <em>non-replaced</em> inline elements, like {{HTMLElement("tt")}} or {{HTMLElement("span")}}.</p>
<p>{{cssbox("margin-bottom")}}</p>
<h2 id="Syntax" name="Syntax">Syntax</h2>
<pre class="twopartsyntaxbox">
<a href="/en-US/docs/CSS/Value_definition_syntax" title="CSS/Value_definition_syntax">Formal syntax</a>: {{csssyntax("margin-bottom")}}</pre>
<pre>
margin-bottom: 10px;        /* An absolute length */
margin-bottom: 1em;         /* A length relative to the text size */
margin-bottom: 5%;          /* A margin relative to the nearest block container's width */
margin-bottom: auto;

margin-bottom: inherit;
</pre>
<h3 id="Values" name="Values">Values</h3>
<dl>
 <dt>
  <code>&lt;length&gt;</code></dt>
 <dd>
  Specifies a fixed width. See {{xref_csslength()}} for possible values.</dd>
 <dt>
  <code>&lt;percentage&gt;</code></dt>
 <dd>
  A {{xref_csspercentage()}} always relative to the <strong>width</strong> of the containing block.</dd>
 <dt>
  <code>auto</code></dt>
 <dd>
  See {{cssxref("margin")}}.</dd>
</dl>
<h2 id="Examples" name="Examples">Examples</h2>
<pre class="brush:css;">
.content { margin-bottom:   5%; }
.sidebox { margin-bottom: 10px; }
.logo    { margin-bottom: -5px; }
#header  { margin-bottom:  1em; }
</pre>
<div>
 {{JSFiddleLink("V3hrF")}}</div>
<h2 id="Specifications">Specifications</h2>
<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>{{SpecName('CSS3 Box', '#the-margin', 'margin-bottom')}}</td>
   <td>{{Spec2('CSS3 Box')}}</td>
   <td>No significant change.</td>
  </tr>
  <tr>
   <td>{{SpecName('CSS3 Transitions', '#animatable-css', 'margin-bottom')}}</td>
   <td>{{Spec2('CSS3 Transitions')}}</td>
   <td>Defines <code>margin-bottom</code> as animatable.</td>
  </tr>
  <tr>
   <td>{{SpecName('CSS2.1', 'box.html#margin-properties', 'margin-bottom')}}</td>
   <td>{{Spec2('CSS2.1')}}</td>
   <td>Removes its effect on inline elements.</td>
  </tr>
  <tr>
   <td>{{SpecName('CSS1', '#margin-bottom', 'margin-bottom')}}</td>
   <td>{{Spec2('CSS1')}}</td>
   <td>Initial definition.</td>
  </tr>
 </tbody>
</table>
<h2 id="Browser_Compatibility" name="Browser_Compatibility">Browser compatibility</h2>
<p>{{CompatibilityTable()}}</p>
<div id="compat-desktop">
 <table class="compat-table">
  <tbody>
   <tr>
    <th>Feature</th>
    <th>Chrome</th>
    <th>Firefox (Gecko)</th>
    <th>Internet Explorer</th>
    <th>Opera</th>
    <th>Safari (WebKit)</th>
   </tr>
   <tr>
    <td>Basic support</td>
    <td>1.0</td>
    <td>{{CompatGeckoDesktop("1")}}</td>
    <td>3.0</td>
    <td>3.5</td>
    <td>1.0 (85)</td>
   </tr>
   <tr>
    <td><code>auto</code> value</td>
    <td>1.0</td>
    <td>{{CompatGeckoDesktop("1")}}</td>
    <td>6.0 (strict mode)</td>
    <td>3.5</td>
    <td>1.0 (85)</td>
   </tr>
  </tbody>
 </table>
</div>
<div id="compat-mobile">
 <table class="compat-table">
  <tbody>
   <tr>
    <th>Feature</th>
    <th>Android</th>
    <th>Firefox Mobile (Gecko)</th>
    <th>IE Phone</th>
    <th>Opera Mobile</th>
    <th>Safari Mobile</th>
   </tr>
   <tr>
    <td>Basic support</td>
    <td>1.0</td>
    <td>{{CompatGeckoMobile("1")}}</td>
    <td>6.0</td>
    <td>6.0</td>
    <td>1.0</td>
   </tr>
  </tbody>
 </table>
</div>
<h2 id="See_also">See also</h2>
<ul>
 <li>{{CSS_Reference:Margin()}}</li>
</ul>
Revert to this revision