views:

45

answers:

1

Should we give overflow:hidden to those div for which we are not giving height?

#Container {width:900px;margin:0 auto}

for #header which has other elements inside then should i give overflow:hidden to #header or i should give fixed height to #header.

What is the difference between both?

#header {}

#footer {}
+2  A: 

No, it's not needed.

That rule is used as a work around to allow a container to take the full height of its child elements when they are floated. So unless you're floating elements inside it, the rule is extraneous, as there will be no overflow because the height is not specified.

See here for more info on why you would use overflow: hidden.

wsanville
Is it same thing if we give fixed height or we give overflow:hidden?
metal-gear-solid
I got your point thanks. so if i give position:relative to #header then give position:absolute for inside elements then also we will not need to clear float
metal-gear-solid
With the exception of using `overflow: hidden` for clearing floats, that rule is used in combination with a fixed height to hide all contents that would appear beyond the fixed height. I'm not exactly clear on what you're trying to achieve with `overflow: hidden`.
wsanville
@wsanville - but as alternative to overflow: hidden we can give fixed height also to parent div to expand parent div to inside elements. quirksmode.org/css/clearing.html then what is the difference giving overflow: hidden or fixed height to parent div?
metal-gear-solid
Something with a fixed height won't expand - the height is fixed.
adam