Utilities
Float
Toggle floats on any element, across any breakpoint, using responsive float utilities.
Overview
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. !important is included to avoid
specificity issues. They use the same viewport breakpoints as the grid.
Floats are for wrapping text around an image or a pull-quote. For laying out boxes side by side, reach for flex or the grid instead — they do not need a clearfix.
HTML
<div class="float-start p-2 bg-body-tertiary border">Float start on all viewport sizes</div><br>
<div class="float-end p-2 bg-body-tertiary border">Float end on all viewport sizes</div><br>
<div class="float-none p-2 bg-body-tertiary border">Don't float on all viewport sizes</div>
The names are logical, not physical: start is float: left in left-to-right
documents and float: right under dir="rtl".
Responsive
Responsive variations also exist for each float value.
HTML
<div class="float-sm-start p-2 bg-body-tertiary border">Float start on viewports sized SM (small) or wider</div><br>
<div class="float-md-start p-2 bg-body-tertiary border">Float start on viewports sized MD (medium) or wider</div><br>
<div class="float-lg-start p-2 bg-body-tertiary border">Float start on viewports sized LG (large) or wider</div><br>
<div class="float-xl-start p-2 bg-body-tertiary border">Float start on viewports sized XL (extra large) or wider</div><br>
<div class="float-xxl-start p-2 bg-body-tertiary border">Float start on viewports sized XXL (extra extra large) or wider</div><br>Here are all the support classes:
.float-start.float-end.float-none.float-sm-start.float-sm-end.float-sm-none.float-md-start.float-md-end.float-md-none.float-lg-start.float-lg-end.float-lg-none.float-xl-start.float-xl-end.float-xl-none.float-xxl-start.float-xxl-end.float-xxl-none
Clearing
A floated element escapes its parent's height. Put .clearfix on the parent to contain it, or
make the parent a flex container (.d-flex) which contains floats automatically. The example
wraps a short bio around a floated poster.
The card was announced on the Saturday morning show. Eight matches, two titles on the line, and a
steel-cage main event that ran past eleven. The text wraps around the poster on the left and the
.clearfix parent stretches to contain it, so the border below sits where it should.
HTML
<div class="clearfix">
<svg class="float-start me-3 mb-2 rounded border" width="120" height="120" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="Placeholder: 120x120"><rect width="100%" height="100%" fill="var(--bs-navy-700)"/><text x="50%" y="50%" fill="var(--bs-gold-300)" dy=".3em" text-anchor="middle" font-size="14">Poster</text></svg>
<p class="mb-0">
The card was announced on the Saturday morning show. Eight matches, two titles on the line, and a
steel-cage main event that ran past eleven. The text wraps around the poster on the left and the
<code>.clearfix</code> parent stretches to contain it, so the border below sits where it should.
</p>
</div>CSS
Generated from the "float" entry of the utilities map with responsive: true.
"float": (
responsive: true,
property: float,
values: (
start: left,
end: right,
none: none,
)
),