View Full Version : 1px height div tag

01-24-2007, 11:33 PM
Okay, I used css to style a div tag, making it 1px in height, and it comes out great, in fact almost everything I code comes out excellent in firefox, but not in ie7, which is the browser client that most people use. Anyways, the div tag shows up in regular height. Anyone no why or how to code it alternatively?
<div style="background-color:#000000;height:1px;width:100%;"></div>

01-25-2007, 12:57 AM
Try font-size: 0; if that doesn’t work, try line-height: 0. I know that Internet Explorer has a bug that forces a minimum height equal to that of one line of text unless you use one or both of the previous declarations anyway. I think you need to add a (pixel) unit or something to the second one (if used) despite the value being zero though.

01-25-2007, 01:21 AM
Thanks! The font-size worked, i didn't try line height though. I still like firefox 2 better than ie7.

01-25-2007, 03:55 AM
No need to specify width:100%; as divs by default unless they are floated, set to display:inline, or position:absolute will take up the full width of its containing element.