This solution is generated by ChatGPT, correctness is not guaranteed.

AI solution for Interview Question on BFE.dev
140. how does `clear` in CSS work?

clear in CSS is a property used to control the behavior of elements in relation to floated elements. When applied to an element, clear specifies if it should be moved below any floated elements that appear before it.

The clear property has four values:

  • none: The element is allowed to float on either side of the floated elements.
  • left: The element will clear all floated elements on the left-hand side, allowing the next element to appear below it.
  • right: The element will clear all floated elements on the right-hand side, allowing the next element to appear below it.
  • both: The element will clear all floated elements on both the left and right-hand sides, allowing the next element to appear below it.

For example, if we apply clear: left; to an element, it will be moved below any floated element on its left-hand side, preventing content from wrapping around the floated element.