Hi everyone.I'm building a website and I have two divs, one below the other.The div below has a margin-top: 40px; property, however, it only works if I float that div or if I display it as table. What is the best way to position divs? I don't like to use floats too much unless I have divs side by side. I also don't like to use relative positioning since the elements are not truly on the flow.Any ideas?Thank you in advance.

Rayzur
—
2011-07-01T18:43:09Z —
#2

it only works if I float that div or if I display it as tableHi,You may have ran into collapsing margins, hard to say without seeing your code though.That's what it sounds like though as margins do not collapse on floats, inline-blocks, or display:table

To un-collapse child margins you can set a top/bottom padding (or border) on the parent or you can also use overflow:hidden.

You should be able to set a class on any element that needs a different margin or target it exclusively if it is already unique.