Skip to content
Justice Tech School

Float Layouts

Before flexbox and grid, floats made columns. They still appear in old code. Clear floats with clear: both or overflow: auto on the parent.

Example
<style>
  .col { float: left; width: 48%; padding: 4px; box-sizing: border-box; background: #1e293b; margin-right: 2% }
  .clear { clear: both }
</style>
<div class="col">Left column</div><div class="col">Right column</div><div class="clear"></div>

Exercise

Clear floats.

clear: ;

Quiz Test

Which modern tools replace floats for layout?

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