Breadcrumb Abstract Shape
Breadcrumb Abstract Shape
Breadcrumb Abstract Shape

CSS Float

CSS CODES & EXAMPLES

CSS Float

Learn how the CSS float property moves elements to the left or right and allows surrounding content to flow around them.

01

What is CSS Float?

Move elements left or right

The float property was originally designed to allow text to wrap around images. It can move an element toward the left or right side of its container.

left

Moves the element toward the left.

right

Moves the element toward the right.

none

Default value. No floating is applied.

inherit

Uses the float value from its parent.

02

float: left

Float an element to the left

With float: left;, the element moves to the left side and surrounding inline content can flow around it.

float-left.css
.image {
  float: left;
  width: 150px;
  margin-right: 20px;
}
FLOAT

CSS float allows text to flow around a floated element. This technique was commonly used for image and article layouts before Flexbox and CSS Grid became widely used. The surrounding content can occupy the remaining space beside the floated element.

Float is still useful when creating certain text-wrapping layouts and when working with older CSS designs.

04

Image with Text Wrapping

A classic float example
image-float.css
img {
  float: left;
  width: 140px;
  margin: 0 20px 10px 0;
}
CSS

The CSS float property can be used to place an image beside article content. Text then flows around the floated image instead of appearing only above or below it.

This was one of the most common uses of float before modern layout systems such as Flexbox and Grid became standard tools for web developers.

Although modern layouts should generally use Flexbox or Grid, understanding float remains important because you will encounter it in existing websites and older CSS code.

05

Multiple Floated Elements

Place elements side by side
multiple-float.css
.box {
  float: left;
  width: 30%;
  margin: 1.66%;
}
BOX 1
BOX 2
BOX 3
06

float: none

Remove floating behavior

The none value is the default. It prevents an element from floating.

float-none.css
.box {
  float: none;
}
FLOAT: NONE

This element follows the normal flow of the document.

07

The Float Container Problem

Why the parent may collapse

Floated elements are taken out of the normal flow. Because of this, a parent containing only floated children can sometimes collapse to zero height.

float-problem.css
.child {
  float: left;
}
FLOAT 1
FLOAT 2

The parent should be cleared or otherwise contain its floated children.

09

Float vs Flexbox

Choose the right layout system

CSS Float

  • Useful for text wrapping
  • Older layout technique
  • Requires clearing
  • Less suitable for complex layouts

CSS Flexbox

  • Designed for modern layouts
  • Easy alignment
  • Excellent for responsive components
  • No traditional clearfix required
10

Float Property Reference

Quick revision
ValueEffectCommon Use
leftMoves element leftImage/text wrapping
rightMoves element rightImage/text wrapping
noneNo floatingDefault behavior
inheritInherits parent’s valueSpecialized layouts
11

Practice Task

Test your CSS skills

🎯 Create an Article Layout

Create an article with an image floated to the left and text wrapping around it.

  • Use float: left;
  • Set the image width.
  • Add right and bottom margin.
  • Add at least three paragraphs.
  • Use clear: both; after the article if needed.
12

CSS Float Live Example

Run the practical example
LIVE PREVIEW
`;document.getElementById( "sncecFloatPreview" ).srcdoc=html;}document.addEventListener( "DOMContentLoaded", function(){sncecFloatRun();} );

CSS Align Self

  • 19/08/2026

HTML CSS

  • 17/08/2026

CSS Box Model

  • 18/08/2026

Leave a Reply

Your email address will not be published. Required fields are marked *