Previous Message
Next Message

Floats with and without containing div

Sent by Ellen Herzfeld on 16 February 2005 22:10


I am having some trouble with floats (no kidding...) and am trying 
out some simple mockups  to get a grip on where the trouble lies 
before asking any stupid questions here.

But before I got anywhere I noticed something I can't find any 
reference to either in The Definitive Guide, on this list or on the 
web, so I'll ask a probably stupid question anyway.

Put two divs directly in the body (margin and padding = 0 on the 
body). A couple of paragraphs in each just to fill them up. Div1 has 
no top margin. Div2 has a top margin. Float div1 left. The top of 
floated div1 acts as if it had a top margin and thus is aligned to 
the top of static div2. It doesn't touch the top of the body. This is 
not what I expected.

Put the two divs in a container div with no margins or padding. Now 
the tops of div1 and div2 are not aligned, div1 has no top margin and 
touches the top of the body. This is the behavior I would expect.

I only looked in Firefox Mac and Safari for this because I didn't 
want to complicate things yet.

Why is this? Where is it described? Must one always put floats in a 
container div? What am I missing?

See the tests here:
http://ansible.xlii.org/web_design/CSS/float_drop/float1.html
http://ansible.xlii.org/web_design/CSS/float_drop/float2.html

Thanks,

Ellen
-- 
Quarante-Deux : quelques pages sur la Science-Fiction
Ellen C. Herzfeld - Dominique O. Martel
http://www.quarante-deux.org/
______________________________________________________________________
css-discuss [EMAIL-REMOVED]]
http://www.css-discuss.org/mailman/listinfo/css-d
List wiki/FAQ -- http://css-discuss.incutio.com/
Supported by evolt.org -- http://www.evolt.org/help_support_evolt/
Previous Message
Next Message

Message thread: