Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does "both" mean in <div style="clear:both">

Tags:

html

css

<div style="float:left">Hello</div>
<div style="float:right">Howdy dere pardner</div>
<div style="clear:both"></div>

I get what it does, but why the name both? What does both mean?

like image 974
Tom Gullen Avatar asked Mar 14 '11 14:03

Tom Gullen


People also ask

How do you clear a float on both sides?

Clearing Floats The footer should sit below both the sidebar and main content. To clear a float, add the clear property to the element that needs to clear the float. This is usually the element after the floated element. The clear property can take the values of left , right , and both .

What does clear mean in CSS?

The clear CSS property sets whether an element must be moved below (cleared) floating elements that precede it. The clear property applies to floating and non-floating elements.

How do you clear a div?

To clear the contents of a div element, set the element's textContent property to an empty string, e.g. div. textContent = '' .

What does the clear right property do?

The clear property is used to specify which side of floating elements are not allowed to float. It sets or returns the position of the element in relation to floating objects. If the element can fit horizontally in the space next to another element which is floated, it will.


2 Answers

Both means "every item in a set of two things". The two things being "left" and "right"

like image 96
Quentin Avatar answered Oct 07 '22 15:10

Quentin


Description of the possible values:

  • left: No floating elements allowed on the left side
  • right: No floating elements allowed on the right side
  • both: No floating elements allowed on either the left or the right side
  • none: Default. Allows floating elements on both sides
  • inherit: Specifies that the value of the clear property should be inherited from the parent element

Source: w3schools.com

like image 26
Sagar Pise Avatar answered Oct 07 '22 14:10

Sagar Pise