Results 1 to 3 of 3

Thread: setting margin and padding anchor block in IE6.

  1. #1
    Join Date
    Dec 2009
    Posts
    12
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default setting margin and padding anchor block in IE6.

    I am debugging some css drop down menus and I have noticed that IE6 is adding extra margin space for it's anchor tag when the css "display" property is set to "block". The menus look fine in IE8 and firefox. I have an example below.

    Question.
    How do you get IE6 to remove or set the margin correctly for an anchor that is a display block?

    In the following case I am just trying to remove the margin between "li" and "a" tags.

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
    <html>
    <head>
    </head>
    <body>
    <div style="display:block;background:red;">
    <ul style="LIST-STYLE-TYPE: none;background:black;margin:0;padding:0;">
    <li style="margin:0;padding:0;">
    <a style="display:block;background:green;">hello</a>
    </li>
    </ul>
    </div>
    </body>
    </html>

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Get rid of two line breaks in your code by moving the closing </li> and </ul> tags as shown:

    Code:
    <html>
    <head>
    </head>
    <body>
    <div style="display:block;background:red;">
    <ul style="LIST-STYLE-TYPE: none;background:black;margin:0;padding:0;">
    <li style="margin:0;padding:0;">
    <a style="display:block;background:green;">hello</a></li></ul>
    </div>
    </body>
    </html>
    Note This works, I guess because those line breaks are interpreted as spaces by IE 6, and one or more spaces following a block level element would produce an additional line.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. The Following User Says Thank You to jscheuer1 For This Useful Post:

    since (12-08-2009)

  4. #3
    Join Date
    Dec 2009
    Posts
    12
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    John,
    Thx a million that solved the problem.

    Steve

Bookmarks

Posting Permissions

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