Skip to content
Justice Tech School

Float and Clear

float pushes an element left or right so text wraps around it. clear stops wrapping. Use flexbox or grid for layouts and float only for text wrapping.

Example
<style>
.f { float: right; width: 60px; height: 60px; background: #f59e0b; margin: 0 0 6px 8px } p { overflow: auto }
</style>
<div class="f"></div><p>Text wraps around the floated square on its left side because the float is moved to the right edge.</p>

Exercise

Float to the right.

float: ;

Quiz Test

What is float best for today?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.