If three values are declared, it is margin: [top] [left-and-right] [bottom];. Any of the individual margins can be declared using longhand, in which case you would define only one value per property: .box { margin-top: 20px; margin-right: 10px; margin-bottom: 20px; margin-left: 10px; }
This property corresponds to the margin-top and margin-bottom, or the margin-right and margin-left properties, depending on the values defined for writing-mode, direction, and text-orientation. The margin-block property may be specified using one or two values. When one value is specified, it applies the same margin to both start and end.
Learn how to contribute. This page was last modified on Jul 17, 2023 by MDN contributors. The margin-block CSS shorthand property defines the logical block start and end margins of an element, which maps to physical margins depending on the element's writing mode, directionality, and text orientation.
The margin property sets the margins for an element, and is a shorthand property for the following properties: Note: Negative values are allowed. yes, see individual properties. Read about animatable Try it The numbers in the table specify the first browser version that fully supports the property.