Float
Float utilities push elements to the left or right and let text wrap around them.
In this page:
Syntax
<div class="float-start">left</div>
<div class="float-end">right</div>
<div class="clearfix"></div>
Float
.float-start and .float-end float elements, .float-none resets, and breakpoint versions such as .float-md-end exist. Floated elements leave the normal flow, so clear them with .clearfix on the parent.
For modern layouts prefer flexbox or the grid over floats.
Note:
Add clearfix to the container of floated children so it wraps them.
Example: Float
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body class="p-3">
<div class="container">
<div class="clearfix border p-2">
<div class="float-start bg-info-subtle p-2 me-2">float-start</div>
<div class="float-end bg-warning-subtle p-2 ms-2">float-end</div>
<p>Text wraps between the floated boxes and the clearfix parent contains them all.</p>
</div>
</div>
</body>
</html>
Live Example
Related Topics
Common Mistakes
- Forgetting clearfix
- Using floats for whole-page layouts
- Using float-left from Bootstrap 4
Chapter Summary
- float-start and float-end
- float-none resets
- Breakpoint versions exist
- Use clearfix on the parent
🔒
Chapter Quiz — Complete all 7 topics to unlock
0/7 topics done
Complete these topics first: