Spacing (margins and paddings) are handled with bootstrap classes. They are named using the format [property][sides]-[breakpoint]-[size]
, where [sides]
and [breakpoint]
are optional values.
property
m
for marginp
for paddingsides
t
for tope
for endb
for bottoms
for startx
for left and righty
for top and bottombreakpoint
sm
Small devices (e.g. phones), at least 576px widemd
Medium devices (e.g. tables), at least 768px widelg
Large devices (e.g. desktops screens), at least 992px widexl
Very large devices (e.g. high resolution desktop screens), at least 1200px widexxl
Very large devices (e.g. high resolution desktop screens), at least 1400px widesize
0-5
an increasing scale starting with nothingauto
for auto, only applicable with m
mt-2
Top margin of size 2px-0
No horizontal paddingm-5
Margin on all sides of size 5mx-auto
Automatic horizontal margin, this will center an element if it has a width and is a block elementmb-lg-5
Bottom margin of size 5 if browser window is wider than lg
<div class="m-5">
This element will have a margin of 5 pixels
</div>
Bootstrap’s own documentation can be found here Bootstrap 5 spacing utilities