Complete 2020 Web Development Bootcamp

Section 5 – Lesson 55 – CSS Float and Clear

The “float” CSS property allows you to position an element to the right or left so that text elements wrap around it. The CSS looks like this –

img {
 float: left;
}

or

img {
 float: right;
}

The CSS “clear” property can be used to ensure that text will not wrap around another element (like an image element) on whatever side is specified. The CSS looks like this when you want the paragraph element not to wrap around another element on its left side –

p {
 clear: left;
}

Float should only be used to wrap text around an element. It should not be used for positioning. Relative and absolute positioning as well as margins and padding should be used for the layout of your website.