Bootstrap has many facilities of classes to easily style elements in HTML. It includes various responsive padding and margin classes for modification of the appearance of elements. Spacing utilities have no breakpoints symbols to apply to the breakpoints.
The following Syntax are used in the Various Classes for adding spacing:
(property)(sides)-(size) for xs (property)(sides)-(breakpoint)-(size) for sm, md, lg, and xl.
Property: There are two ways of adding spacing to the elements.
- m: This property defines the margin. Margin provides an edge or border.
- p: This property defines the padding. Padding properties are used to generate space around the content.
Sides: This allows users to add spacing in content to a specific side wherever required.
t : margin-top/padding-top.
b : margin-bottom/padding-bottom.
l : margin-left/padding-left.
r : margin-right/padding-right.
x : for padding-left and padding-right/margin-left and margin-right.
y : for padding-top and padding-bottom/margin-top and margin-bottom.
blank : margin/padding on all sides of the element.
Size: This allows users to add a specific amount of spacing to a level.
- 0 – 0px margin/padding.
- 1 – 4px margin/padding.
- 2 – 8px margin/padding.
- 3 – 16px margin/padding.
- 4 – 24px margin/padding.
- 5 – 48px margin/padding.
- auto – auto margin.
Breakpoint: Breakpoints are points where the website content can adjust according to the device and allow to show the best layout to the user.
sm, md, lg, and xl are the following breakpoints.
For breakpoint – xs: