CSS float Property

Beginner
5 min read
Updated: Oct 2026
3 examples
Live preview

Definition and Usage

The float property places an element on the left or right of its container so following text and inline content can wrap around it.

Floated elements leave normal flow for placement, but text still wraps beside them. For page grids, prefer Flexbox or Grid. Use float mainly for wrapping text around images — and use clear or display: flow-root when you need to contain floats.

Baseline · Widely available.

Not deprecated and not experimental. left, right, and none work everywhere. Logical values inline-start and inline-end need newer browsers.

CSS Syntax

syntax.css
float: none | left | right | inline-start | inline-end | initial | inherit;

The initial value is none. The property is not inherited.

Property Values

ValueDescriptionTry it
noneDo not float (default). Normal flowTry it
leftFloat to the left; content wraps on the rightTry it
rightFloat to the right; content wraps on the leftTry it
inline-startFloat to the start side (left in LTR, right in RTL)Try it
initialResets to noneTry it
inheritUses the parent’s float valueTry it

How to Use float

Float a sized box, then let following text wrap beside it.

  1. Give the element a width (floated boxes often need an explicit size).
  2. Set float: left or float: right.
  3. Place text or other content after the floated element in the HTML.
  4. If a following block must start below the float, use clear. If a parent collapses, use display: flow-root on the parent.
PieceRequired?Role
float valueYesleft, right, or none
Width on the floatUsuallyGives the box a clear size beside the text
Following contentYes (to see wrapping)Text after the float wraps around it
clear / flow-rootWhen neededStop wrapping or contain floated children

Live Preview

Change only float on the blue box. The paragraph wraps beside it when floated.

left and right pull the box to a side so text can wrap. none keeps normal block flow.

Box

float: left

CSS Examples

Each snippet focuses on float. Width is only there so the floated box has a clear size. Use Try It Yourself for a live editor.

Example 1 — Float Left

Pull a box to the left so paragraph text wraps on the right.

CSS
<style>
  .box {
    float: left;
    width: 80px;
    height: 80px;
    margin: 0 12px 8px 0;
    background: #93c5fd;
    text-align: center;
    line-height: 80px;
  }
</style>

<div class="box">Left</div>
<p>Text wraps on the right of a left-floated box.</p>
Try It Yourself

How It Works

  1. Size the box. A fixed width keeps the float predictable.
  2. Float it left. float: left moves the box to the left edge.
  3. Add following text. The paragraph comes after the box in the HTML.
  4. Text wraps. Lines flow beside the float until they clear its bottom.

Example 2 — Float Right

Pull a box to the right so text wraps on the left.

CSS
<style>
  .box {
    float: right;
    width: 80px;
    height: 80px;
    margin: 0 0 8px 12px;
    background: #fcd34d;
    text-align: center;
    line-height: 80px;
  }
</style>

<div class="box">Right</div>
<p>Text wraps on the left of a right-floated box.</p>
Try It Yourself

How It Works

  1. Same idea, other side. Width and height still define the box.
  2. Float it right. float: right docks to the right edge.
  3. Margin on the left. A small left margin keeps space between text and the box.
  4. Text fills the gap. Content wraps in the space on the left.

Example 3 — No Float

With none, the box stays in normal block flow above the text.

CSS
<style>
  .box {
    float: none;
    width: 80px;
    height: 80px;
    background: #93c5fd;
    text-align: center;
    line-height: 80px;
  }
</style>

<div class="box">None</div>
<p>With float: none, the box is a normal block above the text.</p>
Try It Yourself

How It Works

  1. Default behavior. float: none means no floating.
  2. Block stacking. The box and paragraph sit one under the other.
  3. No side wrap. Text does not sit beside the box.
  4. Compare with left/right. The earlier examples show the wrapping difference.

Edge Cases & Pitfalls

If wrapping or height looks wrong, check these first.

parent

Parents can collapse around floats

A parent that only contains floats may shrink to zero height. Use display: flow-root (or another BFC) on the parent.

clear

Stop wrapping with clear

A following heading or footer that must sit fully below the float needs clear: both (or left/right).

layout

Prefer Flex/Grid for page structure

Floats are awkward for multi-column page shells. Use Flexbox or Grid for those; keep float for text wrapping.

width

Give floated boxes a width

Without a width, a floated box can shrink to its content in ways that surprise beginners. Set an explicit width for demos and images.

logical

inline-start follows direction

In LTR, inline-start matches left. In RTL it matches right. Prefer logical values when direction varies.

Browser Support

float is a browser CSS property for wrapping layout. Node.js, Deno, and Bun do not apply it.

✓ Baseline · Widely available

float

Classic left / right / none work in all major browsers, including Internet Explorer. Logical inline-start / inline-end: Chrome 118+, Firefox 55+, Safari 15+.

99% Classic value support
Google Chrome 1+
Full support
Mozilla Firefox 1+
Full support
Apple Safari 1+
Full support
Microsoft Edge 12+
Full support
Opera 7+
Full support
Samsung Internet 1+
Full support
Internet Explorer 4+
Full support (classic values)
float (none / left / right) Universally supported

Bottom line: Safe everywhere for left, right, and none. Use inline-start / inline-end when you can require modern browsers. It is not a runtime API.

Key Takeaways

  • Role: dock a box left or right so text wraps around it.
  • Best use: images beside paragraphs — not full page grids.
  • Contain or clear: flow-root on parents; clear on later blocks.
  • Initial value: none. Not inherited.

One line: sized box + float: left; + following text = classic wrap-around layout.

Frequently Asked Questions

It moves an element to the left or right of its container so following text and inline content can wrap around it. The element leaves normal flow but still affects layout around it.
The initial value is none. The element stays in normal flow and nothing wraps beside it because of float.
Absolute positioning removes an element from flow completely. A float is taken out of normal flow for placement, but text still wraps around it and it still influences the layout.
Use clear on a following element (often clear: both), or give the parent display: flow-root so it grows around floated children.
For new full-page layouts, prefer Flexbox or Grid. float remains useful for wrapping text around images and for older float-based code.
It is Baseline Widely available. Classic left, right, and none work in all major browsers, including Internet Explorer. Logical inline-start and inline-end need newer browsers. It is a browser CSS property, not a Node.js feature.

Next: font

Set font-style, font-weight, size, and family in one shorthand.

font tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

15 people found this page helpful