Favorites

CSS float Property

float
CSS PropertyThis property is supported by all modern browsers.
Updated 22nd November 2026

The float property moves an element to the left or right side of its container, so text and inline content wrap around it.

Looks like you're using an ad blocker, and that's fine! Ads help keep CSS Portal's generators and references free, so if the site's useful to you, visit our Support page to see other ways to help.

Description

The float property takes an element out of the normal inline flow in a horizontal sense so that other inline content (text, inline elements) can wrap around it. A floated element is shifted to the side of its containing block and subsequent inline-level content flows alongside it until the float ends; however, the float still participates in the block layout in that it affects the vertical placement of following block-level boxes. Because floats influence how surrounding content wraps, they are frequently used for image/text wrapping and for small, flow-sensitive layout pieces where content should flow around a visual element rather than sit above or below it.

Floats interact with the layout of their container in ways that can be surprising: a container that only contains floated children can appear to collapse because floats are taken out of the normal flow for block layout. To manage that interaction you commonly use clearing techniques - for example the clear property on subsequent elements to stop wrapping, or you create a block formatting context for the containing box (often done via properties such as overflow) so the container expands to include its floats. These interactions also influence how margins and adjacent boxes are calculated, so it’s important to think about containment and clearing whenever floats are involved.

In modern layout practice, floats are best treated as a tool for content wrapping and not as a primary mechanism for large-scale page layout. For two-dimensional or responsive layouts, consider layout systems available through the display property or explicit control with the position property, which tend to be clearer and less error-prone. When you do use floats, combine them with explicit clearing or a clearfix pattern so containers behave predictably, and keep an eye on source order and accessibility since floated elements can change how content is perceived by assistive technologies and users navigating by flow.

Definition

Initial value
none
Applies to
All except for positioned elements and generated content
Inherited
No
Computed value
As specified
Animatable
No
JavaScript syntax
object.style.cssFloat

Interactive Demo

Typography is the art of arranging type to make written language legible and appealing. It involves choosing typefaces, sizes, line lengths, line spacing and letter spacing, and adjusting the space between pairs of letters.
Demo Code
HTML Code
<div class="demo-wrap">
	<div class="demo-element"></div>
	Typography is the art of arranging type to make written language legible and appealing. It involves choosing typefaces, sizes, line lengths, line spacing and letter spacing, and adjusting the space between pairs of letters.
</div>
CSS Code
.demo-wrap {
	width: 300px;
	padding: 8px;
	background: #f4f4f4;
	font-size: 14px;
	line-height: 1.5;
	color: #333;
	display: flow-root;
}
.demo-element {
	width: 80px;
	height: 80px;
	margin: 4px 10px;
	background: #f72585;
	border-radius: 6px;
	float: none;
}

Syntax

float: left | right | none | inline-start | inline-end

Values

  • leftThe left value indicates that the element must float to the far left side of its containing block.
  • rightThe right value indicates that the element must float to the far right side of its containing block.
  • noneIndicates that the element does not contain any float at all. This is the initial value of the float property.
  • inline-startThe element floats on the start side of its containing block (left in left-to-right text).
  • inline-endThe element floats on the end side of its containing block (right in left-to-right text).

Example

<div class="float-demo">
<h2>Float property example</h2>
<div class="box float-right">
<strong>Floating box</strong>
<p>Floats to the right.</p>
</div>

<img src="https://placehold.co/150" alt="Placeholder image" class="float-left" />

<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere, nisl at
fermentum elementum, urna purus tristique lorem, a tincidunt risus arcu non
mauris. Vivamus luctus, odio at interdum dictum, neque sapien cursus justo,
vitae volutpat lorem nunc vitae sapien.
</p>

<p>
Curabitur non lectus ac sapien interdum cursus. This paragraph continues to show
how text wraps around floated elements. Resize the container or window to see the
float behavior adapt.
</p>

<div class="clearfix"></div>
</div>
.float-demo {
    max-width: 720px;
    border: 1px solid #e0e0e0;
    padding: 16px;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
    background: #ffffff;
}

.float-left {
    float: left;
    width: 150px;
    height: auto;
    margin: 0 16px 16px 0;
    border-radius: 4px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.float-right {
    float: right;
    width: 140px;
    background: #f7fbff;
    padding: 10px;
    border: 1px solid #dfeef8;
    margin: 0 0 16px 16px;
    box-sizing: border-box;
    border-radius: 4px;
}

.clearfix::after {
    content: "";
    display: table;
    clear: both;
}

/* Small responsive tweak */
@media (max-width: 480px) {
    .float-left,
    .float-right {
        float: none;
        width: 100%;
        margin: 0 0 12px 0;
    }
}
Open in editor

Browser Support

The following information will show you the current browser support for the CSS float property. Hover over a browser icon to see the version that first introduced support for this CSS property.

This property is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported

Looks like you're using an ad blocker, and that's fine! Ads help keep CSS Portal's generators and references free, so if the site's useful to you, visit our Support page to see other ways to help.