- Services
- Case Studies
- Technologies
- NextJs development
- Flutter development
- NodeJs development
- ReactJs development
- About
- Contact
- Tools
- Blogs
- FAQ
CSS Margin-Bottom Mastering Space Control
Discover its use cases and available options, including length, percentage, and auto.
Introduction
The margin-bottom
CSS property lets you control the space between the bottom of an element and the content below it. This is crucial for creating visually appealing and functional web designs. By tweaking this property, you can add extra space for clarity or reduce it for a more compact layout.
Description
The margin-bottom
property sets the space below an element, defining the distance between the element and the content directly beneath it. This is handy for controlling the layout and spacing of web page elements, ensuring a clean and organized design.
The margin-bottom
property can take various values, including lengths, percentages, and keywords like auto
. Positive values increase the space, while negative values decrease it. It’s important to note that this property doesn’t affect non-replaced inline elements like <span>
or <code>
.
Syntax
Here’s the basic syntax for using the margin-bottom
property in CSS:
Values
The margin-bottom
property accepts various values:
- Length: Fixed length values like pixels (
px
), ems (em
), etc. - Percentage: Relative to the width of the containing block.
auto
: Browser automatically calculates a suitable margin value.- Global Values:
inherit
,initial
,revert
,revert-layer
, andunset
.
Formal Definition
Property | Value |
---|---|
Initial Value | 0 |
Applies To | All elements except elements with table display types other than table-caption , table , and inline-table . It also applies to ::first-letter . |
Inherited | No |
Percentages | Refer to the width of the containing block |
Computed Value | The percentage as specified or the absolute length |
Animation Type | A length |
Examples
Setting Positive and Negative Bottom Margins
HTML
CSS
This example shows how to use both positive and negative margins to control the spacing between elements. Positive margins add extra space, while negative margins reduce it, pulling elements closer together.
Specifications
The margin-bottom
property is defined in the CSS Box Model Module Level 3 under the margin-physical
section.
Browser Compatibility
The margin-bottom
property is widely supported across all major browsers, including:
- Google Chrome 1.0
- Edge 12.0
- Internet Explorer 3.0
- Firefox 1.0
- Opera 3.5
- Safari 1.0
See Also
For further reading and related properties, you may also be interested in:
margin-top
,margin-right
, andmargin-left
- The mapped logical properties:
margin-block-start
,margin-block-end
,margin-inline-start
, andmargin-inline-end
- Shorthand properties:
margin
,margin-block
, andmargin-inline
Browser Compatibility for margin-bottom
You can use the margin-bottom
property confidently in your web projects. It’s supported by all major browsers, so you won’t have compatibility issues. Here’s a quick overview of browser support:
Browser | Minimum Version | Release Date |
---|---|---|
Chrome | 1.0 | December 2008 |
Edge | 12.0 | July 2015 |
Firefox | 1.0 | November 2004 |
Internet Explorer | 3.0 | August 1996 |
Opera | 3.5 | November 1998 |
Safari | 1.0 | June 2003 |
Related CSS Properties
For more on CSS margins, check out these related properties:
margin-top
: Sets the space above an element.margin-right
: Sets the space to the right of an element.margin-left
: Sets the space to the left of an element.margin
: Shorthand to set all four margins at once.
Logical Margin Properties
For more flexibility, explore these logical margin properties:
margin-block-start
: Sets the margin at the start of the block.margin-block-end
: Sets the margin at the end of the block.margin-inline-start
: Sets the margin at the start of the inline direction.margin-inline-end
: Sets the margin at the end of the inline direction.margin-block
: Shorthand for block-start and block-end margins.margin-inline
: Shorthand for inline-start and inline-end margins.
These properties help you control spacing and layout, creating dynamic and responsive web designs.
Talk with CEO
We'll be right here with you every step of the way.
We'll be here, prepared to commence this promising collaboration.
Whether you're curious about features, warranties, or shopping policies, we provide comprehensive answers to assist you.