# Float & Clear

# Float


# Clear

The Clear property specifies how elements should behave when they bump into each other on the page. You can clear an element’s left or right side (or both) It can take on one of the following values:

  • left — the left side of the element will not touch any other element within the same containing element

  • right — the right side of the element will not touch any other element within the same containing element

  • both — neither side of the element will touch any other element within the same containing element.

  • none — the element can touch either side

  • Clear - w3schools (opens new window)

  • Clear - MDN (opens new window)


# Clearfix-hack

If an element is taller than the element containing it, and it is floated, it will "overflow" outside of its container. This 'hack' can fix it:

.clearfix {
  overflow: auto;
}
.clearfix::after {
  content: "";
  clear: both;
  display: table;
}  

simple ClearFix:

.clearFix {
  clear: both;
} 
<div class="clearFix"></div>