HTML CSS SQL Meta tag Generator ScrollBar design Generator Encode Decode images

CSS Basics

Introduction Syntax Selectors Attribute Selectors Specificity Combinators !important Comments Colors

CSS Need to Know

Box Model Pseudo-class Pseudo-element Inline-block Math Functions Max and Min Opacity Outline Overflow Z-index Float

Most used

Align Backgrounds Borders Text Units Padding Margins Position Tables Display Fonts Lists Height and Width

CSS Reference

CSS Properties reference CSS Pseudo-Classes reference CSS Pseudo-Elements reference CSS Selector reference

CSS margin-block

The margin-block property is a shorthand property that sets the margin of an element on the block axis. The block axis is the direction in which block-level elements stack. In the case of most languages, the block axis is vertical, from top to bottom.

The margin-block property can take one, two, or three values, which represent the top, right, and bottom margins, respectively. If only one value is specified, it applies to all four sides of the element.

Here is the syntax for the margin-block property:


selector {
  margin-block: value;
}

Let's see some examples with fictional data:

Result:

This is an example of using margin-block: 20px;.

Result:

This is an example of using margin-block: 10px 20px;.

Result:

This is an example of using margin-block: 5px 10px 15px;.

In the first example, the element has a margin of 20 pixels on all sides. In the second example, the top and bottom margins are 10 pixels, and the left and right margins are 20 pixels. In the third example, the top margin is 5 pixels, the right and left margins are 10 pixels, and the bottom margin is 15 pixels.