I tried this:
<div style="height: 1px; width: 500px; background-color: #000; font-size: 0px;"></div>
Very close, but it's two pixels high. Any suggestions?
Main Topics
Browse All TopicsWhat is the ideal way to create a 1 pixel high horizontal line without using spacer .gifs that works in IE? For Mozilla or Opera I could do this:
<div style="height: 1px; width: 500px; background-color: #000;"></div>
However, IE pads the line with about 10 pixels on either side above and below. I need a 1 pixel high line without any padding so that elements above and below can be flush. I would like to do this through CSS if possible. I know that I could put a 1 pixel high transparent .gif within the div to fix the IE bug, but that seems like a crutch.
Am I going about this the wrong way?
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
abilstein,
I'm fine with your last comment as a solution.
Note: "Depending on your layout", you can always use the border-bottom property on other elements to achieve a similar cross-broswer effect.
<html>
<head>
<style type="text/css">
p { margin:0px; padding:0px; }
</style>
</head>
<body>
<p style="border-bottom:1px solid #f00; width:500px;">y-descender text</p>
<p>h-ascender text</p>
</body>
</html>
Sean, thanks for the help. Being new to EE, I'm not exactly sure how I'm supposed to handle the resolution of this question.
I didn't want to "Accept" your first answer since it didn't solve the problem down to the pixel and I didn't want to lead anyone astray who came upon it. However, without your answer I wouldn't have figured this out. I tried to give partial credit as an assisted answer, but it won't let me do without accepting a solution. I would also like to make it clear that the solution I posted works, so other people see that easily. How should I handle this?
Thanks abilstein for your diligence and concern.
In this case, the only solution posted here that fully satisfies your objectives is your own. Also my fault for not checking IE's rendering engine on the first post :-)
However, since that solution was based on previous comments, my preference here would be a point split, but give you the accepted answer for the correct format.
Are you both comfortable with this as a resolution?
Guys,
Sorry for being daft here, but what are you suggesting I do? I wanted to give partial credit to both of you (zoobie's line-height inclusion was also part of the eventual solution) with more weight going to seanpowell's answer. The solution I posted was exactly what I was looking for, but of course I can't Accept my own Comment. So, what should I do to Accept an answer and split points?.
jSkipB, Even if you specify a negative top margin,(as I have below) hr will still insert a line break below the hr:
This text will be flush with the hr
<hr style="border: none; background-color: #000; height: 1px;margin-top:-.5em;">
This text will be not be flush with the line above
The negative margin will align your text flush with the top, but margin values cannot get it to align flush with the bottom.
So, you want it on the same line as your text:
- Put the line in a TABLE cell (TD|TH), then, in the same row, put the HR (as I've shown) in surrounding cells with specified widths:
<table width="100%"><tr>
<td width="10"><hr></td><td>Te
</tr></table>
- Try the FIELDSET with the LEGEND tags. This underused tag works in the popular browser, and adds a clean, application-style look to your pages. You can modify the FIELDSET appearance as I did the HR tag in your stylesheet.
skip
Business Accounts
Answer for Membership
by: seanpowellPosted on 2004-02-21 at 19:41:41ID: 10423817
Just need to remove the default font height...
div>
Line of text
<div style="font-size:0px; height:1px; width:500px; background-color:#000;"></
Another line of text