The float property positions an element to the left or right and lets text wrap around it. It is a classic CSS layout tool that remains useful for images in articles and legacy layouts.
01
float: left
Align left.
02
float: right
Align right.
03
Text wrap
Flow around.
04
Default none
Normal flow.
05
Clear floats
Avoid collapse.
06
Modern alt
Flex & Grid.
Fundamentals
Introduction
The float property in CSS is used to position an element to the left or right within its container, allowing text and inline elements to wrap around it. This property has been widely used in web design for creating layouts, although modern techniques like Flexbox and Grid have largely replaced it for complex designs.
Definition and Usage
Apply float: left or float: right on an element such as an image, badge, or sidebar block. The floated element is taken out of normal flow, and surrounding content flows beside it on the opposite side. Use margins to add space between the float and wrapped text.
💡
Beginner Tip
Float is still a great choice when you want text to wrap around an image in a blog post. For full page layouts, prefer Flexbox or Grid instead.
Foundation
📝 Syntax
The syntax for the float property is straightforward. It can be applied to any block-level element and accepts specific keyword values:
The default value of the float property is none, meaning the element does not float and behaves as a normal block-level or inline element in document flow.
Syntax Rules
Apply on the element you want to pull left or right — commonly images, figures, or sidebars.
Accepts keyword values: none, left, right, and inherit.
Floated elements are removed from normal flow; siblings may wrap beside them.
Parent containers may collapse in height unless floats are cleared.
The property is not inherited (use inherit explicitly if needed).
Cheat Sheet
⚡ Quick Reference
Question
Answer
Initial value
none
Applies to
All elements
Inherited
No
Value type
Keyword (none, left, right, inherit)
Common use
Images with wrapping text; legacy column layouts
Reference
💎 Property Values
Value
Description
none
The element does not float. This is the default value and keeps normal document flow.
left
The element floats to the left of its container. Content wraps on the right side of the element.
right
The element floats to the right of its container. Content wraps on the left side of the element.
inherit
The element inherits the float value from its parent element.
Float and document flow
When an element floats, it is shifted as far left or right as possible within its containing block. Block boxes below it behave as if the float were not there, while inline content wraps around the floated box.
Preview
👀 Live Preview
A thumbnail floated left with margin-right — paragraph text wraps naturally beside and below it:
Photo
The float property is useful for simple layouts where elements need to align left or right within their container. By floating the image to the left, surrounding text flows to the right, creating a visually appealing arrangement.
Hands-On
Examples Gallery
In this example, we’ll float an image to the left so text wraps around it — plus float right, a two-column layout, and clearing floats with a clearfix.
🖼 Text Wrapping
Start with the reference example — an image floated left with wrapping paragraph text.
Example 1 — Float an Image Left
Float an image to the left and add right margin so text does not touch the image edge.
float-left.html
<style>.float-left{float:left;margin-right:20px;}</style><imgsrc="photo.jpg"alt="Example"class="float-left"><p>
This paragraph wraps around the floated image on the right side.
</p>
Both columns float left and sit side by side when their combined width fits. This was a common pattern before Flexbox and Grid, but still appears in older codebases.
Example 4 — Clearfix Container
Prevent a parent from collapsing when it only contains floated children.
Without clearing, a parent's background may not wrap floated children. A clearfix pseudo-element forces the container to expand. See also the CSS clear property.
A11y
♿ Accessibility
Keep meaningful alt text on floated images so screen reader users understand the content.
Do not rely on float order alone for reading sequence — DOM order should match the intended narrative.
Ensure sufficient spacing between floated elements and text for readability and touch targets.
Test zoomed layouts — narrow floated columns can become hard to read on small screens.
Prefer semantic HTML like figure and aside when floating media or side content.
🧠 How float Works
1
Element is taken out of flow
The floated box is shifted left or right as far as possible within its containing block.
Out of flow
2
Inline content wraps beside it
Text and inline elements flow on the opposite side of the float, then continue below it.
Text wrap
3
Following blocks may overlap
Block boxes behave as if the float were not there unless you clear floats or use a clearfix.
Clear needed
=
🖼
Wrapped content layout
Images and side elements sit beside flowing text without complex grid setup.
Compatibility
🖥 Browser Compatibility
The float property is supported in all modern browsers and has been part of CSS since its early days. It works consistently across browsers, making it a reliable choice for simple layout tasks.
✓ Baseline · Universal support
float everywhere
Left, right, none, and inherit all work consistently in every browser, including legacy environments.
99%Universal support
Google ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions
Full support
OperaAll modern versions
Full support
float property99% supported
Bottom line:float is universally supported. Pair it with clear or a clearfix when containing floated children.
Wrap Up
🎉 Conclusion
The float property is a useful tool for web developers, particularly for simple tasks like aligning images within text. While it has been largely supplanted by more advanced layout techniques such as Flexbox and Grid, understanding how to use float effectively remains valuable for maintaining and updating legacy code or for specific design needs.
Experiment with the float property to see how it can enhance your web layouts. For beginners, remember: default is none, use left or right for wrapping content, and always clear floats when a parent must contain floated children.
Use float: left or right for images with wrapping text
Add margin on the wrapped-text side for breathing room
Clear floats or use a clearfix on parent containers
Prefer Flexbox or Grid for new multi-column page layouts
Learn the clear property alongside float
❌ Don’t
Build entire responsive sites with floats alone today
Forget to clear floats — parents may collapse visually
Float elements without considering mobile readability
Assume float changes DOM reading order for assistive tech
Stack many nested floats without a clear containment strategy
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about float
Use these points when wrapping content or reading legacy CSS.
5
Core concepts
←→01
Left or right
Pulls element aside.
Purpose
none02
Default none
Normal flow.
Default
📄03
Text wrap
Inline flows around.
Behavior
🛠04
Clear floats
Contain children.
Pattern
📈05
Modern alt
Flex & Grid.
Today
❓ Frequently Asked Questions
The float property positions an element to the left or right of its container and removes it from normal document flow so inline content and text wrap around it.
The default value is none, which means the element does not float and stays in normal block or inline flow.
float: left pulls the element to the left side of its container and content wraps on the right. float: right pulls it to the right side and content wraps on the left.
Use the clear property on a following element (often clear: both), or apply a clearfix technique to the parent container so it expands to contain floated children.
For new layouts, Flexbox and Grid are usually better choices. float is still useful for wrapping text around images and for maintaining legacy float-based code.