intermediate
Floats & Clearfix
Legacy layout tool with modern containment and clearfix recipes.
Learning checklist
- Float stacking rules
- clearfix techniques
- BFC and containment
Definition
Legacy layout tool with modern containment and clearfix recipes.
Syntax
Example
Deep dive
Why this matters
Principles, mental models, and debugging clues tailored to the topic.
Visual intuition
Each property is paired with motion or color feedback so you build muscle memory, not just recall syntax.
Copy-ready CSS
Controls emit exact CSS you can copy. Use it as a starter token or paste into DevTools for instant validation.
Performance notes
Learn where reflow, repaint, or compositing occurs so you avoid jank and choose GPU-friendly paths.
Accessibility first
Focus-visible, reduced-motion, and contrast tips are woven into every lab to keep experiences inclusive.
Practice
Try recreating a UI card using this topic. Toggle between dark and light modes to validate token contrast and responsiveness.
Tip: use DevTools overlays (grid/flex) plus the copy CSS button.
Floats & Clearfix
Toggle float direction and clearfix to see how surrounding text wraps.
Try these
- Float left vs right and watch text wrap.
- Disable clearfix to see parent collapse.
- Set float to none to restore normal flow.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras porttitor, quam a vulputate volutpat, elit ante condimentum magna, nec ultrices ligula nisi nec leo. Vivamus placerat magna vitae dui.
Donec euismod, nisl eget consectetur tempor, nisl nunc aliquet nibh, id ultrices nisl nunc eget lorem.
.float-box { float: left; width: 160px; }
.clearfix { overflow: auto; }<div class="clearfix"> <div class="float-box">Floated card</div> <p>Lorem ipsum dolor sit amet...</p> </div>