DHTML/horizontal rule tag causing additional white space
Expert: Andrew Hoffman - 5/22/2007
QuestionHello Andrew:
Unfortunately I found out the hard way that <hr> property is interpreted differently by most browsers, especially IE, which creates additional white space below the horizontal line.
I tried defining properties like border, padding, line space, etc., but nothing helps.
If you want to see what I mean, here is the link to my website,
http://lauramohanty.com/Resume.html In mozilla it's fine, and I validated the CSS code. However, I.E., it looks different with the extra spacing. This minor detail is driving me bonkers!
Have you experienced a problem similar to this before? Is there something I can try to elimate white space with <HR>, I really don't want to use any images if possible.
Thanks again for your help!
-Laura
AnswerI've had this happen too, and zeroing out the padding and margins doesn't seem to solve this problem in IE. What I've done as a workaround is to use a centered div with a fixed height and width. Copy and paste this chunk to see what I mean (works happily with IE too):
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style type="text/css">
div.hz_line {
height: 2px;
background: #ccc;
width: 600px;
text-align: center;
margin: 0 auto;
}
#container {
width: 800px;
}
</style>
</head>
<body>
<div id="container">
<p>content here content here content here content here content here content here content here content here content here content here content here content here content here content here</p>
<div class="hz_line"></div>
<p>content here content here content here content here content here content here content here content here content here content here content here content here content here content here</p>
</div>
</body>
</html>