Bootstrap includes dozens of utilities—classes with a single purpose. They're designed to reduce the frequency of highly repetitive declarations in your CSS while allowing for quick and easy development.
Assign `margin` or `padding` to an element or a subset of its sides with shorthand classes. Includes support for individual properties, all properties, and vertical and horizontal properties. All classes are multiples on the global default value, `1rem`.
Convey meaning through color with a handful of emphasis utility classes. These may also be applied to links and will darken on hover just like our default link styles.
{% example html %}
<pclass="text-muted">Fusce dapibus, tellus ac cursus commodo, tortor mauris nibh.</p>
<pclass="text-primary">Nullam id dolor id nibh ultricies vehicula ut id elit.</p>
<pclass="text-success">Duis mollis, est non commodo luctus, nisi erat porttitor ligula.</p>
<pclass="text-info">Maecenas sed diam eget risus varius blandit sit amet non magna.</p>
<pclass="text-warning">Etiam porta sem malesuada magna mollis euismod.</p>
<pclass="text-danger">Donec ullamcorper nulla non metus auctor fringilla.</p>
Similar to the contextual text color classes, easily set the background of an element to any contextual class. Anchor components will darken on hover, just like the text classes.
{% example html %}
<divclass="bg-primary">Nullam id dolor id nibh ultricies vehicula ut id elit.</div>
<divclass="bg-success">Duis mollis, est non commodo luctus, nisi erat porttitor ligula.</div>
<divclass="bg-info">Maecenas sed diam eget risus varius blandit sit amet non magna.</div>
<divclass="bg-warning">Etiam porta sem malesuada magna mollis euismod.</div>
<divclass="bg-danger">Donec ullamcorper nulla non metus auctor fringilla.</div>
Sometimes contextual classes cannot be applied due to the specificity of another selector. In some cases, a sufficient workaround is to wrap your element's content in a `<div>` with the class.
Use a generic close icon for dismissing content like modals and alerts. **Be sure to include text for screen readers**, as we've done with `aria-label`.
These utility classes float an element to the left or right, or disable floating, based on the current viewport size using the [CSS `float` property](https://developer.mozilla.org/en-US/docs/Web/CSS/float). `!important` is included to avoid specificity issues. These use the same viewport width breakpoints as the grid system.
Two similar non-responsive mixins (`pull-left` and `pull-right`) are also available.
Easily clear `float`s by adding `.clearfix`**to the parent element**. Utilizes [the micro clearfix](http://nicolasgallagher.com/micro-clearfix-hack/) as popularized by Nicolas Gallagher. Can also be used as a mixin.
The `.invisible` class can be used to toggle only the visibility of an element, meaning its `display` is not modified and the element can still affect the flow of the document.
Hide an element to all devices **except screen readers** with `.sr-only`. Combine `.sr-only` with `.sr-only-focusable` to show the element again when it's focused (e.g. by a keyboard-only user). Can also be used as mixins.
{% comment %}
Necessary for following [accessibility best practices](../getting-started/#accessibility).
Allow browsers to determine video or slideshow dimensions based on the width of their containing block by creating an intrinsic ratio that will properly scale on any device.
Rules are directly applied to `<iframe>`, `<embed>`, `<video>`, and `<object>` elements; optionally use an explicit descendant class `.embed-responsive-item` when you want to match the styling for other attributes.
**Pro-Tip!** You don't need to include `frameborder="0"` in your `<iframe>`s as we override that for you.