Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons

© 2026 BraveProgrammer. All rights reserved.

  1. Courses
  2. /
  3. CSS Basics to Advanced

Lesson 12 of 50 · css

Floating & Clearing

Duration: 8 mins

Historically, float let text wrap around images.

  • float:left or float:right – element is taken out of normal flow and moves to either side.
  • clear:left|right|both – forces an element to start below floated elements.

Modern layouts rarely need floats; Flexbox/Grid are preferred. However, floats are still needed for inline image wrap.


Example: Image with text wrap

<img src="portrait.jpg" alt="Portrait" style="float:left; margin:0 1rem 1rem 0;" width="150" />
<p>Long paragraph that wraps around the image...</p>
Previous: PositioningNext: Overflow & Scrollbars