clear
Published Jul 31, 2021Updated Jan 18, 2024
Contribute to Docs
Specifies whether an element coming after a floated element should be moved down or not.
Syntax
clear: value;
The value
for the clear
attribute can be:
none
: The element is not moved down to clear past floating elements (the default).left
: The element is moved down to clear past left floated elements.right
: The element is moved down to clear past right floated elements.both
: The element is moved down to clear past both left and right floated elements.
Example 1
Making an img
element move down a left floated h1
element.
.div1 h1 {float: left;}.div1 img {clear: left;}
The image below matches the code example. The h1
element is floated to the left due to float: left
. The img
element is then moved under the h1
element due to clear: left
.
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn CSS on Codecademy
- Career path
Front-End Engineer
Front-end engineers work closely with designers to make websites beautiful, functional, and fast.Includes 34 CoursesWith Professional CertificationBeginner Friendly115 hours - Career path
Full-Stack Engineer
A full-stack engineer can get a project done from start to finish, back-end to front-end.Includes 51 CoursesWith Professional CertificationBeginner Friendly150 hours - Free course
Learn CSS
In this CSS tutorial, you’ll learn how to add CSS to visually transform HTML into eye-catching sites.Beginner Friendly6 hours