CSS marginbottom Property (original) (raw)

CSS margin-bottom Property

Last Updated : 28 May, 2026

The margin-bottom property in CSS is used to add space below an element. It helps maintain proper spacing between elements in a webpage layout.

**Syntax:

margin-bottom: | | auto

**Property values:

**Example:

html `

CSS margin-bottom
<style>
    div{
        background-color: lightgreen;
    }
</style>

GeeksforGeeks

<!-- margin-bottom for below div 
    is set to 50px -->
<div style="margin-bottom: 50px">Line One</div>

<!-- margin-bottom for below div 
    is set to 0px -->
<div style="margin-bottom: 0px">Line Two</div>

<div>Line Three</div>

`

**Example:

html `

CSS margin-bottom
<style>
    h1 {
        color: green;
    }
    
    .larger {
        width: 300px;
        background-color: white;
    }
    
    .smaller {
        width: 100px;
        background-color: white;
    }
    
    div{
        background-color: lightgreen;
    }
</style>

GeeksforGeeks

<!-- margin-bottom is set to 10% with width of 
    containing box set to 300px -->
<div class="larger">
    <div style="margin-bottom: 10%";>Line One</div>
    <div>Line Two</div>
</div>

<!-- margin-bottom is set to 10% with width of 
    containing box set to 100px -->
<div class="smaller">
    <div style="margin-bottom: 10%;">Line One</div>
    <div>Line Two</div>
</div>

`