Forum Moderators: not2easy

Message Too Old, No Replies

<hr> misalignment

         

rakan

11:12 pm on Sep 22, 2005 (gmt 0)

10+ Year Member



I got my horizontal menu up and going thanks to the advice I received on this forum. I have another question. When I add a <hr> after my menu_box div it looks like the <hr> is coming out of the right side of my horizontal menu when I look at it in FF. In IE it looks okay. Why is there this discrepancy and how do I fix it? Here is my code...

CSS code:

#menu_box{
width:675px;
margin:0 auto;
}

#menu_box ul{
padding: 0;
margin: 0;
}

#menu_box li{
float: left;
list-style-type: none;
}

#menu_box a{
text-align:center;
display: block;
font: 900 9pt arial;
width:125px;
text-decoration:none;
color:#ffffff;
background-color:#000075;
padding:4px 4px;
border:1px solid #ffffff;
}

#menu_box a:hover{
background-color:#850000;
}

HTML Code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<link rel="stylesheet" type="text/css" href="main.css" title="Default">
</head>

<body>

<center>
<div id="menu_box">
<ul>
<li><a href="index.htm">Home</a></li>
<li><a href="archives.htm">Archives</a></li>
<li><a href="why.htm">Why</a></li>
<li><a href="links.htm">Links</a></li>
<li><a href="contact.htm">Contact Me</a></li>
</ul>
</div>
</center>
<hr>

</body>
</html>

jetboy

11:32 pm on Sep 22, 2005 (gmt 0)

10+ Year Member



hr { clear: both; }

rakan

11:49 pm on Sep 22, 2005 (gmt 0)

10+ Year Member



Thanks. That works. I noticed that IE gives me a little extra space between the bottom of my menu and the top of my <hr>. I wish IE would stop doing stuff I don't specify. Oh well.

jetboy

12:17 am on Sep 23, 2005 (gmt 0)

10+ Year Member



One of the issues with <hr /> I'm afraid. Browser styling's hit and miss. Try:

div.hr {
clear: both;
height: 1px;
font-size 0;
background: #000;
}

hr {
display: none;
}

<div class="hr"><hr /></div>

An extra element, but you get to keep the semantic weight of the <hr /> and get decent cross-browser compatibility.