CSS Basic
CSS Styling
CSS Box Model
CSS Advanced
| CSS Floating |
What is CSS Float?With CSS float, an element can be pushed to the left or right, allowing other elements to wrap around it. Float is very often used for images, but it is also useful when working with layouts. How Elements FloatElements are floated horizontally, this means that an element can only be floated left or right, not up or down. A floated element will move as far to the left or right as it can. Usually this means all the way to the left or right of the containing element. The elements after the floating element will flow around it. The elements before the floating element will not be affected. If an image is floated to the right, a following text flows around it, to the left:
Floating Elements Next to Each OtherIf you place several floating elements after each other, they will float next to each other if there is room. Here we have made an image gallery using the float property:
Turning off Float - Using ClearElements after the floating element will flow around it. To avoid this, use the clear property. The clear property specifies which sides of an element other floating elements are not allowed. Add a text line into the image gallery, using the clear property:
An image with border and margins that floats to the right in a paragraph An image with a caption that floats to the right Let the first letter of a paragraph float to the left Creating a horizontal menu Creating a homepage without tables All CSS Float PropertiesThe number in the "CSS" column indicates in which CSS version the property is defined (CSS1 or CSS2).
|
CSS Floating
