0
0
Bootsrapmarkup~10 mins

Float and clear utilities in Bootsrap - Browser Rendering Trace

Choose your learning style9 modes available
Render Flow - Float and clear utilities
[Read HTML with float class] -> [Create DOM nodes] -> [Apply float CSS rules] -> [Recalculate layout with floated elements] -> [Apply clear utility if present] -> [Paint elements] -> [Composite final view]
The browser reads the HTML, creates the DOM, applies float styles which take elements out of normal flow, recalculates layout to wrap text or other elements around floats, then applies clear utilities to control where following elements appear.
Render Steps - 3 Steps
Code Added:<div class="float-start">Float Start Box</div>
Before
[container]
|___________|
|           |
|           |
|___________|
After
[container]
|[Float Start Box]____|
|                     |
|                     |
|_____________________|
The float-start class makes the box float to the left inside the container, so it moves to the left edge and text or other content can flow around it.
🔧 Browser Action:Creates a float formatting context and triggers reflow to position the floated element.
Code Sample
Two boxes float left and right inside a container, and a third box clears the floats so it appears below them.
Bootsrap
<div class="container">
  <div class="float-start">Float Start Box</div>
  <div class="float-end">Float End Box</div>
  <div class="clear-fix">Clearfix Box</div>
</div>
Bootsrap
.float-start { float: left !important; }
.float-end { float: right !important; }
.clear-fix { clear: both !important; }
Render Quiz - 3 Questions
Test your understanding
After applying step 2, where are the two floated boxes positioned inside the container?
ABoth boxes stacked vertically on the right
BBoth boxes stacked vertically on the left
COne box on the left edge, one box on the right edge
DBoth boxes centered horizontally
Common Confusions - 2 Topics
Why does the container collapse in height when it only has floated children?
Floated elements are taken out of normal flow, so the container doesn't see their height and collapses. Using a clear utility or clearfix restores container height.
💡 Floats don't expand parent height; clear floats or add clearfix to fix.
Why doesn't the clear-fix box appear beside the floats?
Because clear: both forces the element to move below all floated elements, so it cannot sit beside them.
💡 Clear moves element below floats, never beside.
Property Reference
PropertyValue AppliedEffect on ElementCommon Use
floatleftElement floats to the left, taken out of normal flowAlign images or boxes to left with text wrapping
floatrightElement floats to the right, taken out of normal flowAlign images or boxes to right with text wrapping
clearleftElement moves below any left-floated elementsPrevent overlap with left floats
clearrightElement moves below any right-floated elementsPrevent overlap with right floats
clearbothElement moves below all floated elementsClear all floats to start fresh line
Concept Snapshot
Float utilities move elements left or right, taking them out of normal flow. Clear utilities move elements below floated elements to avoid overlap. Floated elements do not expand parent height. Use clear or clearfix to fix container height collapse. Float-start = float left, float-end = float right, clear-fix = clear both.