What is the use of float property in CSS?
The float property moves an element to the left or right, and the text and inline content wrap around it. It is mostly used to place an image inside a paragraph.
img.photo { float: left; margin: 0 12px 8px 0; }
.footer { clear: both; }
clear stops the next element from wrapping around the float. A parent does not grow around floated children, so a clearfix is needed. Today we use Flexbox or Grid for layouts. See CSS Float and Clear.
Learn more about the similar topics:
| Tutorials |
|---|
| CSS Layout – The display Property |
| CSS Position Property |
| CSS z-index |
| CSS Float and Clear Property |
| Exercises & Assignments |
|---|
| Write CSS to centre a box horizontally using margin auto |
| Write CSS to create a horizontal navigation menu |