This has been driving me nuts...

Why do my "hello"s float to below the bottom of the content in the leftnav? I want them beside the "there"s so they read "hello there"

thanks for your help

<html>
<head>
<style>
#container
{
    font-family: Tahoma, Arial, Helvetica, sans-serif;
    font-size: small;
    color: #180945;
    line-height: 1.5em;
}
#header {
padding: .5em;
background-color: #ddd;
border-bottom: 1px solid gray;
}
#leftnav
{
float: left;
width: 160px;
margin: 0;
padding: 1em;
}
#content
{
margin-left: 200px;
border-left: 1px solid gray;
padding: 1em;
}
#footer
{
clear: both;
color: #333;
background-color: #ddd;
border-top: 1px solid gray;
}
dt {
    float: left;
    clear: left;
    width: 6em;
    padding:0;
    margin:0;
}
dd { 
    margin-left: 8em; 
    margin-top: 0px;
    padding-bottom: 5px;
}
</style>
</head>
<body>
<div id="container">
    <div id="header">
        Header
    </div>    
<div id="leftnav">
<p>
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut.
</p>
</div>
<div id="content">
<h2>Subheading</h2>
<dl>
<dt>hello</dt><dd>there</dd>
<dt>hello</dt><dd>there</dd>
<dt>hello</dt><dd>there</dd>
</dl>
<p>
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.
</p>
</div>
<div id="footer">
Footer
</div>
</div>
</body>
</html>

1 answer

1
point

the dl isn't containing the floated children, either float the dl or add overflow:hidden to it.

e.g.

dl
{
    overflow:hidden;
}
Answered over 6 years ago by Tony Crockford