I understand that the “overflow” property determines what to do with “the excess part” of something, for example, to hide or to put a scrollbar. In the example, if I erase the “overflow” property, then the background color becomes white. Why is that? I am getting confused of how it works. What was the overflow supposed to be hiding there? Why can’t the “ul” have a background color without the “overflow:hidden”?
Browser just place the floated item either at the left or right. by default the floated advance(width and height) does not affect the parent advance. So it simply could go after parent boundary.
Now when you ask the parent(either div above, or ul in link sample code ) for overflow: hidden;, it’s asking the browser try to apply advance for the element, becasue we don’t want to draw any scroll.
Now becasue of that overflow: hidden;, the advance of floated objects are calculated(affects) the parent advance. So this is becasue you see the gray background.
As you can see, the ul element has 0px height. that red border we applied on our ul tag just shows up as a line. But the text (Home, News, Contact, About) is still there… just not obvious since it’s white text on white background.
Problem is the ul tag has collapsed without any height.
Personally, I would use a height property here, instead of doing overflow: hidden.
I think the intent is clearer.