Layout
float :
The CSS float property specifies how an element should float on a layout. CSS float property is used to positioning and formatting content.
float property values are :
- left - The element floats to the left of its container
- right - The element floats to the right of its container
- By default float property value is none
Example :
HTML
CSS
This will produce the following result −
clear :
The CSS clear property specifies what elements can float beside the cleared element and on which side. The most common way to use the clear property is after you have used a float property on an element.
clear property values are :
- none - Allows floating elements on both sides. This is default
- left - No floating elements allowed on the left side
- right- No floating elements allowed on the right side
- both - No floating elements allowed on either the left or the right side
Example :
HTML
CSS without clear property
This will produce the following result −
CSS with clear property
This will produce the following result −