SystemTutor
About
Sign in
Loading course documentation…
SystemTutor

COURSES

  • Data Structures & Algorithms
  • CSS MasterclassNew course
  • System DesignNew course

PRACTICE

  • Algorithm practice
  • CSS practice

LEGAL

  • Privacy Policy
  • Terms of Service
  • About

© 2026 SystemTutor. All rights reserved.

Built with 🫶 by Shatlyk

Welcome to CSS
The Box Model and SizingWriting Modes and Logical PropertiesSizing ElementsBorders and ShadowsDisplay and Document FlowNormal FlowFloats and ColumnsPositioning and StackingStacking and Z-Index Measuring boxes and predicting their positions
Box Model and Flow

Floats and Columns

Use floats, clearing, and multicolumn layouts.

Some layouts need text to wrap around a small box or continue from one column into another. Floats and multicolumn layout handle these reading patterns without positioning every piece of content individually.

Wrap text around a float

A float moves a box to one side of its container and lets surrounding inline content wrap around it.

.fact {
  box-sizing: border-box;
  float: left;
  width: 10rem;
  max-width: 100%;
  margin: 0 1rem 1rem 0;
  padding: 1rem;
  background-color: honeydew;
}

The fact box moves to the left. The paragraph stays in normal flow, but its first lines use the space beside the float’s margin box. Lines below the float regain the full width. Narrow the article and watch which word first appears below the fact box.

First lines of the project brief start beside the floated fact box. The final line extends back to the article’s left edge beneath the float’s margin.

Start content below a float

To start a heading below the fact box, put the heading after the paragraphs, inside the same article. Give it a clearing class.

.fact {
  box-sizing: border-box;
  float: left;
  width: 10rem;
  max-width: 100%;
  margin: 0 1rem 1rem 0;
  padding: 1rem;
  background-color: honeydew;
}

.next {
  clear: both;
}

clear: both moves the heading below earlier floats on either side within the same block layout region. Use left or right to clear just one side.

Clearing changes where the following box begins. It does not turn the earlier float back into an ordinary in-flow box.

Contain floats with flow-root

A parent with automatic height can end before the bottom of a tall floated child because that child is out of normal flow. This is especially noticeable when the parent's only child is a float.

.article {
  display: flow-root;
  padding: 1rem;
  border: 1px solid green;
}

flow-root creates a separate block layout region, called a block formatting context. The parent grows tall enough to contain its floats, and outside floats cannot push into its content.

The fact box still floats and the article’s text still wraps around it. flow-root contains the float without clipping content that overflows.

Flow an article through columns

Multicolumn layout divides one continuous content stream into columns. For a separate example, use a section with several paragraphs:

.column-text {
  column-width: 16rem;
  column-gap: 2rem;
  column-rule: 1px solid lightgray;
}

column-width suggests a column width. The browser works out how many columns fit and adjusts their widths. A narrow container can have one column smaller than the suggested width.

column-gap sets the space between columns. column-rule draws a dividing line in that gap without adding extra width. To request a particular number instead, use a declaration such as column-count: 2.

Content continues down one column and then into the next; it is not a set of independent card tracks. A heading can span all columns with column-span: all. For a short grouped item, break-inside: avoid requests that it stay together when space permits.

Key Takeaways

  • Floats: Move a box to one side so nearby inline content can wrap around it.
  • Clearing: clear places a following box below relevant preceding floats.
  • Containment: display: flow-root lets a parent contain floats without clipping overflow.
  • Columns: Multicolumn layout flows one content stream through several columns.
  • Reading order: Content runs down a column before continuing into the next one.

Try it yourself

Try it yourself

Wrap a summary around a fact box

HTML + CSS

Loading code editor…

Live preview

Updating…

Final output

No comparison yetChecks after 3s without edits
Loading your draft…

How is this lesson?

Previous lessonNormal FlowNext lessonPositioning and Stacking
Edit on GitHubReport on GitHub
On this page
%

On this page

Wrap text around a floatStart content below a floatContain floats with flow-rootFlow an article through columnsKey TakeawaysTry it yourself