What are responsive utility classes in bootstrap?

For faster mobile-friendly and responsive development, Bootstrap includes dozens of utility classes for showing, hiding, aligning, and spacing content.

Changing display

Use our display utilities for responsively toggling common values of the display property. Mix it with our grid system, content, or components to show or hide them across specific viewports.

Flexbox options

Bootstrap 4 is built with flexbox, but not every element’s display has been changed to display: flex as this would add many unnecessary overrides and unexpectedly change key browser behaviors. Most of our components are built with flexbox enabled.

Should you need to add display: flex to an element, do so with .d-flex or one of the responsive variants (e.g., .d-sm-flex). You’ll need this class or display value to allow the use of our extra flexbox utilities for sizing, alignment, spacing, and more.

Margin and padding

Use the margin and padding spacing utilities to control how elements and components are spaced and sized. Bootstrap 4 includes a five-level scale for spacing utilities, based on a 1rem value default $spacer variable. Choose values for all viewports (e.g., .mr-3 for margin-right: 1rem), or pick responsive variants to target specific viewports (e.g., .mr-md-3 for margin-right: 1rem starting at the md breakpoint).

Toggle visibility

When toggling display isn’t needed, you can toggle the visibility of an element with our visibility utilities. Invisible elements will still affect the layout of the page, but are visually hidden from visitors.



Bootstrap provides some handful helper classes, for faster mobile-friendly development. These can be used for showing and hiding content by device via media query, combined with large, small, and medium devices.

Use these sparingly and avoid creating entirely different versions of the same site. Responsive utilities are currently only available for block and table toggling.

ClassesDevices
.visible-xs Extra small (less than 768px) visible
.visible-sm Small (up to 768 px) visible
.visible-md Medium (768 px to 991 px) visible
.visible-lg Larger (992 px and above) visible
.hidden-xs Extra small (less than 768px) hidden
.hidden-sm Small (up to 768 px) hidden
.hidden-md Medium (768 px to 991 px) hidden
.hidden-lg Larger (992 px and above) hidden

The following table lists the print classes. Use these for toggling the content for print.

ClassesPrint
.visible-print Yes Visible
.hidden-print Visible only to browser not to print.

Example

The following example demonstrates the use of above listed helper classes. Resize your browser or load the example on different devices to test the responsive utility classes.

✔ Visible on x-small
✔ Visible on small
Medium ✔ Visible on medium
✔ Visible on large

Checkmarks indicates that the element is visible in your current viewport.

What are utility classes in Bootstrap?

Bootstrap 4 has a lot of utility/helper classes to quickly style elements without using any CSS code..
Borders. Use the border classes to add or remove borders from an element: ... .
Border Color. ... .
Border Radius. ... .
Float and Clearfix. ... .
Responsive Floats. ... .
Center Align. ... .
Width. ... .
Height..

What is responsive Bootstrap?

Bootstrap includes a responsive, mobile first fluid grid system that appropriately scales up to 12 columns as the device or viewport size increases. It includes predefined classes for easy layout options, as well as powerful mixins for generating more semantic layouts.

What are Bootstrap 5 utilities?

The utility API is a Sass-based tool to generate utility classes. Bootstrap utilities are generated with our utility API and can be used to modify or extend our default set of utility classes via Sass.

Is Bootstrap a responsive framework?

Bootstrap is the most popular HTML, CSS, and JS framework for developing responsive, mobile first projects on the web.