question about lists with css

Discussion in 'CSS' started by sudhakararaog, Sep 23, 2009.

  1. #1
    i am using the following code to display a vertical list, this code
    works fine in all browsers except for ie6, in ie6 there is a lot of
    vertical gaps between each list item which is not the case in other
    browsers and the gap in other browsers appears normally as per the css
    code i have written.

    <div class="contentright">
    <div class="listright">
    <ul>
    <li><a href="#">List item1</a></li>
    <li><a href="#">List item2</a></li>
    <li><a href="#">List item3</a></li>
    <li><a href="#">List item4</a></li>
    <li><a href="#">List item5</a></li>
    </ul>
    </div>

    </div>

    .contentright .listright{
    float: left;
    width: 254px;
    height: 140px;
    margin: 0 0 0 0;

    }

    .contentright .listright ul
    {
    font: normal 11px Arial, Helvetica, sans-serif;
    list-style-type: none;
    margin: 0 0 0 0;
    width: 254px;

    }

    .contentright .listright ul li
    {
    margin: 0 0 0 0;

    }

    #contentouter .contentright .listright ul li a
    {
    display: block;
    padding: 7px 0 0 25px;

    }

    i have 2 horizontal list in the page above this vertical list which is
    causing problem in ie6. i have also given the hierarchy in the css for
    this vertical list which is causing the problem in ie6

    can anyone suggest how to fix this.

    thanks.
     
    sudhakararaog, Sep 23, 2009 IP
  2. wd_2k6

    wd_2k6 Peon

    Messages:
    1,740
    Likes Received:
    54
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Because both <ul> and <li> have different default margins and paddings applied to them by different browsers. So unless you set these, or reset them to 0, the default will be applied, and different browsers use different values.

    Use this to reset all defaults to:
    * { margin:0; padding:0; }

    or just for your list:

    .contentright .listright ul, .contentright .listright ul li { margin:0; padding:0; }

    Change it to a value you need.

    I'm assuming this is the problem if it's the gap in between each list-item.
     
    wd_2k6, Sep 23, 2009 IP
  3. sudhakararaog

    sudhakararaog Member

    Messages:
    73
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #3
    thanks for replying.

    i have tried all the options

    i already have * {margin: 0; padding: 0;} and explicitly set margin and padding to the ul li to 0

    i also tried commenting the 2 horizontal list i have above this vertical list and commented the horizontal lists html and css code however the vertical list in ie6 still has the excessive height between each list items.

    in all other browsers i do not have this problem it is only with ie6

    please advice.

    thanks
     
    sudhakararaog, Sep 23, 2009 IP
  4. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #4
    kk5st, Sep 23, 2009 IP
  5. sudhakararaog

    sudhakararaog Member

    Messages:
    73
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #5
    thank you very much

    that worked and has fixed the problem for ie6.

    what could have been the problem just for my information.

    thanks
     
    sudhakararaog, Sep 23, 2009 IP
  6. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #6
    If you're replying to me, read the article I referenced. If you need clarification, ask for more info based on related specifics.

    cheers,

    gary
     
    kk5st, Sep 23, 2009 IP