Performance: Float and clear utilities
Float and clear utilities affect layout calculation and visual stability during page rendering.
<div class="float-start">Left</div> <div class="float-start">Right</div> <div class="clearfix"></div> <div>Content below floats</div>
<div class="float-start">Left</div> <div class="float-start">Right</div> <div>Content below floats</div>
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Floats without clear | Normal DOM nodes | Multiple reflows due to layout shifts | Higher paint cost from unstable layout | [X] Bad |
| Floats with .clearfix | Normal DOM nodes plus clear element | Single reflow with stable layout | Lower paint cost due to visual stability | [OK] Good |
float-start do to an element?float-start in Bootstrap floats an element to the start side of the container, which is left in left-to-right languages.float-start class floats the element to the left side of its container. This matches 'It floats the element to the left side of its container.' Other options describe floating right, centering, or clearing floats.clearfix to clear floats and prevent wrapping issues.clearfix is the correct class name. The other options like float-clear, clear-fix, and clear-start do not exist in Bootstrap.<div> <div class="float-end">Box A</div> <div>Box B</div> </div>
float-end floats Box A to the right side of the container.<div> <div class="float-start">Left Box</div> <div class="float-end">Content Box</div> </div>
float-start on Left Box and float-end on Content Box take both children out of normal flow, causing the parent container to collapse.clearfix to the parent container clears floats, forcing it to expand and contain the floated children properly.float-start to float left as required.clearfix to the second box or its container to clear the float.Pass the test and this pattern moves unknown