Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8

Thread: HR margin

  1. #1
    New Coder
    Join Date
    Jul 2004
    Location
    france
    Posts
    94
    Thanks
    0
    Thanked 0 Times in 0 Posts

    HR margin

    I am trying to get a line with no margin

    hr
    {
    height:1px;
    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

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Quote Originally Posted by quentin
    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;

  • #3
    New Coder
    Join Date
    Jul 2004
    Location
    france
    Posts
    94
    Thanks
    0
    Thanked 0 Times in 0 Posts
    why don't you read before answering

    it doesn't work with margin:0

  • #4
    Senior Coder chilipie's Avatar
    Join Date
    Jul 2004
    Location
    Shrewsbury, UK Age: 16
    Posts
    1,117
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Perhaps try setting the padding to 0 as well?

  • #5
    Senior Coder
    Join Date
    Jun 2002
    Location
    The Netherlands, Baarn, Ut.
    Posts
    4,253
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Anyones guess

    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.

    Edit:
    I did a little delving and trying, and this little article 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.
    Last edited by ronaldb66; 03-15-2005 at 03:54 PM.
    Regards,
    Ronald.
    ronaldvanderwijden.com

  • #6
    New Coder
    Join Date
    Jul 2004
    Location
    france
    Posts
    94
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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 ////

  • #7
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    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

  • #8
    New Coder
    Join Date
    Jul 2004
    Location
    france
    Posts
    94
    Thanks
    0
    Thanked 0 Times in 0 Posts
    yes sorry

    my margin was allways larger than 2px of course

    thank you


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •