Bootstrap provides utility classes for common CSS properties. These utility classes help you quickly style elements without writing custom CSS.
Bootstrap includes a wide range of shorthand responsive margin, padding, and gap utility classes to modify an element's appearance.
The classes are named using the format: {property}{sides}-{size}
m - for marginp - for paddingt - topb - bottoms - start (left in LTR)e - end (right in LTR)x - left and righty - top and bottom0 - eliminates margin or padding1 - 0.25rem (4px)2 - 0.5rem (8px)3 - 1rem (16px)4 - 1.5rem (24px)5 - 3rem (48px)auto - auto margin
<div class="m-3">Margin all sides: 1rem</div>
<div class="mt-4">Margin top: 1.5rem</div>
<div class="p-3">Padding all sides: 1rem</div>
<div class="py-4">Padding top & bottom: 1.5rem</div>
Bootstrap comes with a wide array of color utility classes for text, backgrounds, and borders.
.text-primary
.text-secondary
.text-success
.text-danger
.text-warning
.text-info
.text-light
.text-dark
.text-muted
.text-white
<p class="text-primary">.text-primary</p>
<div class="p-3 mb-2 bg-success text-white">.bg-success</div>
<div class="p-3 mb-2 bg-primary bg-gradient text-white">.bg-primary.bg-gradient</div>
Bootstrap provides various text utilities to control alignment, wrapping, weight, and more.
Left aligned text on all viewport sizes.
Center aligned text on all viewport sizes.
Right aligned text on all viewport sizes.
Right aligned on viewports sized SM (small) or wider.
Right aligned on viewports sized MD (medium) or wider.
Right aligned on viewports sized LG (large) or wider.
Right aligned on viewports sized XL (extra-large) or wider.
LOWERCASED TEXT.
uppercased text.
capitalized text.
Bold text.
Bolder weight text (relative to the parent element).
Normal weight text.
Light weight text.
Lighter weight text (relative to the parent element).
Italic text.
Text with normal font style
<p class="text-center">Center aligned text.</p>
<p class="text-uppercase">uppercased text.</p>
<p class="fw-bold">Bold text.</p>
Use border utilities to quickly style the border and border-radius of an element.
<div class="p-3 border">.border</div>
<div class="p-3 border border-danger">.border-danger</div>
<div class="p-3 border rounded-pill">.rounded-pill</div>
Quickly and responsively toggle the display value of components and more with display utilities.
<div class="d-inline p-2 bg-primary text-white">.d-inline</div>
<div class="d-none d-lg-block">Hidden on screens smaller than lg</div>
<div class="d-print-none">Screen Only (Hide on print only)</div>
Quickly manage the layout, alignment, and sizing of grid columns, navigation, components, and more with a full suite of responsive flexbox utilities.
<div class="d-flex">...</div>
<div class="d-flex flex-row-reverse">...</div>
<div class="d-flex justify-content-center">...</div>
<div class="d-flex align-items-center">...</div>
Use these shorthand utilities for quickly configuring the position of an element.
Use .position-fixed to position an element relative to the viewport, which means it always stays in the same place even if the page is scrolled.
Use .position-sticky to position an element based on the user's scroll position. A sticky element toggles between relative and fixed, depending on the scroll position.
<div class="position-relative">
<div class="position-absolute top-0 start-0">Top left</div>
<div class="position-absolute top-0 end-0">Top right</div>
<div class="position-absolute bottom-0 start-0">Bottom left</div>
<div class="position-absolute bottom-0 end-0">Bottom right</div>
</div>