Rob Clement
Rob Clement

Reputation: 113

Why do I get a white line when I clear:both?

I'm trying to get h1 to appear on the left and h2 on the right, which I've managed to do thanks to a previous post on stackoverflow. But now there is this white line showing up under the text that is seriously messing with my design. Any thoughts?

<div id="container">
  <div id="header">
    <h1 style="text-align:left;float:left;">Ken DeRosier</h1>
    <h2 style="text-align:right;float:right;">Master Sculptor</h2> 
    <hr style="clear:both;">
    <!-- end #header -->
  </div>
  ...
</div>

This is all the CSS I can think of that could be affecting the code above.

body  {
    margin: 0; /* it's good practice to zero the margin and padding of the body element to account for differing browser defaults */
    padding: 0;
    text-align: center; /* this centers the container in IE 5* browsers. The text is then set to the left aligned default in the #container selector */
    color: #FFFFbb;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 100%;
    background-color: #000000;
    background-repeat: no-repeat;
    background-position: center top;
    background-image: url(../images/sunriseHeader.jpg);
}
.thrColLiqHdr #container { 
    width: 80%;  /* this will create a container 80% of the browser width */
    margin: 0 auto; /* the auto margins (in conjunction with a width) center the page */
    border: 0px solid #000000;
    text-align: left; /* this overrides the text-align: center on the body element. */
} 
.thrColLiqHdr #header {
    padding: 0 10px;
    padding-top: 170px;
    padding-right: 20px;
} 
.thrColLiqHdr #header h1 {
    margin: 0; /* zeroing the margin of the last element in the #header div will avoid margin collapse - an unexplainable space between divs. If the div has a border around it, this is not necessary as that also avoids the margin collapse */
    padding: 10px 0; /* using padding instead of margin will allow you to keep the element away from the edges of the div */

Upvotes: 0

Views: 245

Answers (2)

pdu
pdu

Reputation: 10413

I think this is because you use a <hr> aka "horizontal rule". Why don't you try to use a span or a div or something else to clear which is not intended to display itself with something visible?

Upvotes: 2

Deepak Bhagchandani
Deepak Bhagchandani

Reputation: 46

Try replacing this line

<hr style="clear:both;">

with this

<div style="clear:both;"></div>

Upvotes: 3

Related Questions