I've created a jsFiddle to help explain: http://jsfiddle.net/windthorst/BvgZK/
But here is the HTML right here, for reference:
<header>
<div id="titlebar">
<div id="titlename">
<h1>Title Name Here</h1>
</div>
<div id="titlemenu">
<span>Item One</span><span>Item two</span>
</div>
</div>
</header>
I know that by adding the CSS tag float: left
to both of the inner divs (#titlename and #titlemenu) I can have them line up side by side correctly in the containing div (#titlebar). It took a moment to figure out, but that's done.
What I'm wondering is: why do they position the way they do in the jsFiddle, without the floats? When there is no text in the first div (removing the <h1>
tag here), the second div positions so that the <span>
text inside it "rests" along the bottom of the containing div (#titlebar), and when there is no text in either they both position "correctly" (to my estimation) within the containing div.
Sorry to bother with the "why," but I'm totally stumped on how to avoid struggling with such issues in the future if I don't know what's actually going on here...