float pushes an element to the left or right so text wraps around it, just like an image in a newspaper.
float: left/float: right/float: noneclear: bothmakes an element start below any floats.
Wrap text around images.
✍️ 3 exercises + code challenge in this lessonfloat pushes an element to the left or right so text wraps around it, just like an image in a newspaper.
float: left / float: right / float: noneclear: both makes an element start below any floats.Mastering CSS Float & Clear helps you write clean and reliable CSS code. Follow standard conventions, test edge cases, and keep logic simple. Try running the code example below and complete the exercises to build confidence.
<style>
img { float: left; margin: 0 14px 8px 0; border-radius: 8px; }
.footer { clear: both; background: #071A2F; color: white; padding: 8px; }
</style>
<img src="https://picsum.photos/id/1062/120/90" alt="Dog" width="120" height="90">
<p>This text wraps around the floated image. Float was once used for whole page layouts, but today its main job is letting text flow around pictures, just like in a magazine article. Keep typing to see more lines wrap.</p>
<div class="footer">This footer uses clear: both</div>
Check what you learned in “CSS Float & Clear”.
Float the image to the right.
img {
float: ;
}
Which property makes an element start below floated elements?
Float the image to the left.
Free sign-in required · Google login available
Stuck on something?
Ask the community in the CodesInTech forum.
Need a developer?
Learning on your own is great — and when you need professional help, our team builds custom software, websites and mobile apps for clients worldwide.
Explore Our Services