You are here:

DHTML/horizontal rule tag causing additional white space

Advertisement


Question
Hello 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


Answer
I'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>

DHTML

All Answers


Answers by Expert:


Ask Experts

Volunteer


Andrew Hoffman

Expertise

Ask me about JavaScript, CSS, HTML5/XHTML, or PHP. Chances are I'll be able to help you. I know the economy is in the tank, but if you like my answer, please consider donating a few bucks. It's like tipping your barista, if your barista served fresh code instead of coffee.

Experience

I started doing this when boy bands were still cool.

Education/Credentials
I read a lot of nerdy books to get here.

©2012 About.com, a part of The New York Times Company. All rights reserved.