Float Property

Last updated: 2026-09-13

float Float Property

The float property takes an element out of the normal flow and floats it left or right until its edge touches the containing block or another floated element. Originally designed for wrapping text around images, it was later used heavily for multi-column layouts; now that Flexbox and Grid are widespread, it has returned to its original purpose.

Category
Initial Valuenone
InheritedNo
Applies Toall
Animation Typediscrete
CSS VersionCSS1
StatusStandard

📝 Syntax

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

⚙️ Values

ValueTypeDescription
left | right | noneKeywordThe direction the element floats.

▶ Example

Edit the code below and see the live result in the playground:

🌐 Browser Support

Browser ChromeChrome EdgeEdge FirefoxFirefox SafariSafari OperaOpera
float v1 v12 v1 v1 v1
Supported in all major browsers
Warning: A floated element leaves the document flow, so its parent may lose awareness of its height and collapse. Common ways to clear floats: overflow:hidden on the parent, or a ::after pseudo-element.
Tip: For multi-column layouts, prefer Flexbox or Grid; float is better suited to native scenarios like wrapping text around images.

❓ FAQ

QHow do I clear floats?
AThree common approaches: first, overflow:hidden or auto on the parent, wrapping the floated children in a BFC; second, the pseudo-element method, which is recommended: .clearfix::after{content:'';display:block;clear:both}; third, display:flow-root on the parent. All three make the parent contain its floated children again and recover the collapsed height. In new code, flow-root is the most elegant, while the clearfix class still appears in most existing codebases.
QWhat's the difference between float and display:inline-block?
Afloat takes the element out of the flow and pushes it left or right, letting following content wrap around it, and the parent may collapse in height. inline-block keeps the element in the flow, arranges it horizontally with no wrapping effect, and leaves default whitespace gaps between items, which can be removed with font-size:0. In short, float is for text wrapping and early column layouts, while inline-block is for horizontal lists and navbars.
QWhy does float collapse the parent's height?
AA floated element leaves the normal flow, so the parent cannot perceive its height and assumes there is nothing inside, collapsing to zero or to the height of non-floated content only. The fix is to make the parent contain the float again: overflow:hidden or auto creates a BFC, a clearfix pseudo-element clears it, or display:flow-root does the same. Flex and grid containers do not collapse in this way at all.
QIs float still necessary in modern layouts?
AFor layout, basically no: Flexbox and Grid have fully replaced float for multi-column and horizontal arrangements, offering more control with no float-clearing burden. float now serves its original purpose of wrapping text around images, like newspaper typography. If you just need items side by side in a new project, prefer flex, and reserve float for the rare cases where text should flow around a shape.

📚 Related Tutorials

Web-Tutorial.com

Web-Tutorial Tech Team

A team of developers maintaining programming tutorials. Each tutorial is written and reviewed by developers with expertise in that field. We work to keep our content accurate and reliable — if you spot an issue, please let us know.

100%

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏