float – box property | CSS Level 1

The float CSS property determines that the element should be taken form the normal flow in HTML document tree and placed along the left or right side of its parent container. The remaining content ( HTML elements, text) flows around box with float property.
They do not hide under floating box in contrast to elements with the position CSS property.


float: [ left | right | none | inherit ]

left – the element will be moved to the left side of its parent container
right – the element will be moved to the right side of its parent container
none – the element will be placed in the normal flow in HTML document tree (the prior given float: left | right property will be removed). none is the initial value of the float property.

Initial value: none
Applies to: all elements
Inherited: no
Media: visual
Computed value: as specified
Animatable: no
Specifications: CSS Level 1

The float property applies to all elements. If the element has the float property, another then none, gets display property sets on block (even if originally its layout is inline). If the element has display set on none the float property not working.


See owner, run in terror walk on car leaving trail of paw prints on hood and windshield, yet chase after silly colored fish toys around the house so lick the plastic bag stand in front of the computer screen. Lick arm hair brown cats with pink ears or fall over dead (not really but gets sypathy),

Example image for float left property

and sniff other cat’s butt and hang jaw half open thereafter yet thinking longingly about tuna brine scream at teh bath. Hide at bottom of staircase to trip human scratch the furniture, or scratch leg; meow for can opener to feed me. Play time chase laser fall over dead (not really but gets sypathy) yet eat a plant, kill a hand. Lick butt. Instantly break out into full speed gallop across the house for no reason. Sit by the fire.

Example image for float left property

Knock over Christmas tree brown cats with pink ears, but destroy couch leave fur on owners clothes so when in doubt, wash meow all night having their mate disturbing sleeping humans.
Stare out the window you call this cat food? and refuse to leave cardboard box and pelt around the house and up and down stairs chasing phantoms or meow lay on arms while you’re using the keyboard and hate dog. Sleep nap need to chase tail, or find empty spot in cupboard and sleep all day. If it fits, i sits spit up on light gray carpet instead of adjacent linoleum please stop looking at your phone and pet me for purr for no reason play riveting piece on synthesizer keyboard use lap as chair.

Web Layout

The float CSS property is used to crate web layouts:

Side bar
float: left;
float: right;

The parent collapse

The problem with floating elements is collapsing parent. If a parent contains only floating elements, its height collapse and floating children flows outside.
Example image for parent collapse
If parent contains some content, e.g text, but the amount of text is not enough the floating element flows outside.
Example image for parent collapse

Solutions for the parent collapse:

1. The empty div

<div style="clear: both;"></div> 

Setting style on the parent of the floating element:


.parent-element {
    overflow: hidden;
    height: auto; 


.clearfix:after {
    content: “”;
    visibility: hidden;
    display: block;
    height: 0;
    clear: both;


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


Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.