See this demo page.
The floated box is shifted to the left or right until its margin edge touches the padding edge of the containing block
Correct. The div
labeled First item
is offset a total of 30px
, due to the 10px
of padding on its container and 20px
due to its margins.
or the margin edge of another floated element
Also correct. Notice how there is a total of 40px
between First item
and Second item
, due to both elements having 20px
of margins all around.
Updated for comments: Floating an element takes it out of the normal flow of the document. That is, non-floated elements will not "make room" for floated elements. In most examples, using overflow: hidden;
to clear floats is equivalent to the other methods, so I use it because it's less markup. For more info, see the Quirksmode article and a counter example for overflow hidden.