float property specifies whether or not an element should float.
clear property is used to control the behavior of floating elements.
In its simplest use, the
float property can be used to wrap text around images.
The following example specifies that an image should float to the right in a text:
clear property is used to control the behavior of floating
Elements after a floating element will flow around it. To avoid this, use the
clear property specifies on which sides of an element
floating elements are not allowed to float:
If an element is taller than the element containing it, and it is floated, it will overflow outside of its container.
Then we can add
overflow: auto; to the containing element to fix
It is common to do entire web layouts using the
An image with border and margins that floats to the right in a paragraph
Let an image float to the right in a paragraph. Add border and margins to the image.
An image with a caption that floats to the right
Let an image with a caption float to the right.
Let the first letter of a paragraph float to the left
Let the first letter of a paragraph float to the left and style the letter.
Creating a horizontal menu
Use float with a list of hyperlinks to create a horizontal menu.
Creating a homepage without tables
Use float to create a homepage with a header, footer, left content and main content.
|clear||Specifies on which sides of an element where floating elements are not allowed to float||left
|float||Specifies whether or not an element should float||left