View Full Version : HR margin

Mar 15th, 2005, 03:24 AM
I am trying to get a line with no margin

margin:2px 0;

doesnt work

i get bottom and top spaces bigger than 2px

even adding line-height:1px; and font-size:1px; does not fix it

how can i do it ?

thank you

Mar 15th, 2005, 03:48 AM
I am trying to get a line with no margin

how can i do it ?

thank you
By default I dont think HR's have a margin but if they do then if you want NO margin then dont put one or just put margin:0px;

Mar 15th, 2005, 03:58 PM
why don't you read before answering

it doesn't work with margin:0

Mar 15th, 2005, 04:20 PM
Perhaps try setting the padding to 0 as well?

Mar 15th, 2005, 04:28 PM
According to the W3C:

The amount of vertical space inserted between a rule and the content that surrounds it depends on the user agent.

So it's anyones guess what it turns out to be. If you want more control over the appearance, you could use a border or background image on another element instead.

I did a little delving and trying, and this little article (http://maxdesign.com.au/presentation/hr.cfm) on Maxdesign should help styling hrs; I've tried them on IE6.0/Win2000 and any hr, no matter what line-height, font-size, margin or padding setting is will occupy about an normal line's height, with the actual rule in the middle.

I managed to pull it up with a negative margin, but the total space remained equal; then I remembered IE rendering it as an inline element, so I set display to block; with negative top and bottom margins (little under half a line height), the total height of the hr shrank to the line itself and tiny slivers of whitespace.

Mar 15th, 2005, 07:11 PM
thanks ronald that is what I wanted to know ... then i shall use something else

it will be usefull to use hr as a real line ////

Mar 15th, 2005, 08:41 PM
i did read thats y i quoted ur saying u said a line with no margin but yet u added margin to the hr so rather than get into a big argument im just trying to help we are all volunteers here no need to get hostile

Mar 15th, 2005, 09:25 PM
yes sorry

my margin was allways larger than 2px of course

thank you