1Use the margin and padding spacing utilities to control how elements and
2components are spaced and sized. Bootstrap 4 includes a five-level scale for
3spacing utilities, based on a 1rem value default $spacer variable. Choose
4values for all viewports (e.g., .mr-3 for margin-right: 1rem), or pick
5responsive variants to target specific viewports (e.g., .mr-md-3 for
6margin-right: 1rem starting at the md breakpoint).
7
8<div class="my-0 bg-warning">Margin Y 0</div>
9 <div class="my-1 bg-warning">Margin Y 1</div>
10 <div class="my-2 bg-warning">Margin Y 2</div>
11 <div class="my-3 bg-warning">Margin Y 3</div>
12 <div class="my-4 bg-warning">Margin Y 4</div>
13 <div class="my-5 bg-warning">Margin Y 5</div>
14 <div class="my-auto bg-warning">Margin Y Auto</div>
1The classes are named using the format {property}{sides}-{size} for xs
2and {property}{sides}-{breakpoint}-{size} for sm, md, lg, and xl.
3
4Where property is one of:
5
6m - for classes that set margin
7p - for classes that set padding
8
9Where sides is one of:
10
11t - for classes that set margin-top or padding-top
12b - for classes that set margin-bottom or padding-bottom
13l - for classes that set margin-left or padding-left
14r - for classes that set margin-right or padding-right
15x - for classes that set both *-left and *-right
16y - for classes that set both *-top and *-bottom
17blank - for classes that set a margin or padding on all 4 sides of the element
18
19Where size is one of:
20
210 - for classes that eliminate the margin or padding by setting it to 0
221 - (by default) for classes that set the margin or padding to $spacer * .25
232 - (by default) for classes that set the margin or padding to $spacer * .5
243 - (by default) for classes that set the margin or padding to $spacer
254 - (by default) for classes that set the margin or padding to $spacer * 1.5
265 - (by default) for classes that set the margin or padding to $spacer * 3
27auto - for classes that set the margin to auto
28
29$spacer defaults to 1rem
1The classes are named using the format {property}{sides}-{size} for xs
2and {property}{sides}-{breakpoint}-{size} for sm, md, lg, and xl.
3
4Where property is one of:
5
6m - for classes that set margin
7p - for classes that set padding
8
9Where sides is one of:
10
11t - for classes that set margin-top or padding-top
12b - for classes that set margin-bottom or padding-bottom
13l - for classes that set margin-left or padding-left
14r - for classes that set margin-right or padding-right
15x - for classes that set both *-left and *-right
16y - for classes that set both *-top and *-bottom
17blank - for classes that set a margin or padding on all 4 sides of the element
18
19Where size is one of:
20
210 - for classes that eliminate the margin or padding by setting it to 0
221 - (by default) for classes that set the margin or padding to $spacer * .25
232 - (by default) for classes that set the margin or padding to $spacer * .5
243 - (by default) for classes that set the margin or padding to $spacer
254 - (by default) for classes that set the margin or padding to $spacer * 1.5
265 - (by default) for classes that set the margin or padding to $spacer * 3
27auto - for classes that set the margin to auto
28
29$spacer defaults to 1rem
30