View Full Version : 1px height div tag

Jan 24th, 2007, 10: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>

Jan 24th, 2007, 11:57 PM
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.

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

Jan 25th, 2007, 02: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.