diff --git a/docs/styles/margin.md b/docs/styles/margin.md index 41bb34a04..a7543f24e 100644 --- a/docs/styles/margin.md +++ b/docs/styles/margin.md @@ -1,29 +1,40 @@ # Margin -The `margin` rule adds space around the entire widget. Margin may be specified with 1, 2 or 4 values. - -| Example | Description | -|--------------------|----------------------------------------------------------------------| -| `margin: 1;` | A single value sets the margin around all 4 edges. | -| `margin: 1 2;` | Two values sets the margin for the top/bottom and left/right edges. | -| `margin: 1 2 3 4;` | Four values sets top, right, bottom, and left margins independently. | - -Margin may also be set individually by setting `margin-top`, `margin-right`, `margin-bottom`, or `margin-left` to a single value. +The `margin` rule specifies spacing around a widget. ## Syntax -``` -margin: ; /* Same value for the 4 edges. */ -margin: ; -/* top/bot, left/right */ -margin: ; -/* top, right, bottom, left */ +--8<-- "docs/snippets/syntax_block_start.md" +margin: <integer> + # one value for all edges + | <integer> <integer> + # top/bot left/right + | <integer> <integer> <integer> <integer>; + # top right bot left -margin-top: ; -margin-right: ; -margin-bottom: ; -margin-left: ; -``` +margin-top: <integer>; +margin-right: <integer>; +margin-bottom: <integer>; +margin-left: <integer>; +--8<-- "docs/snippets/syntax_block_end.md" + +The `margin` specifies spacing around the four edges of the widget equal to the [``](../css_types/integer.md) specified. +The number of values given defines what edges get what margin: + + - 1 [``](../css_types/integer.md) sets the same margin for the four edges of the widget; + - 2 [``](../css_types/integer.md) set margin for top/bottom and left/right edges, respectively. + - 4 [``](../css_types/integer.md) set margin for the top, right, bottom, and left edges, respectively. + +!!! tip + + To remember the order of the edges affected by the rule `margin` when it has 4 values, think of a clock. + Its hand starts at the top and the goes clockwise: top, right, bottom, left. + +Alternatively, margin can be set for each edge individually through the rules `margin-top`, `margin-right`, `margin-bottom`, and `margin-left`, respectively. + +### Values + +--8<-- "docs/snippets/type_syntax/integer.md" ## Examples