Why is a space being treated like a line break in IE?

Discussion in 'CSS' started by Phoenixaz, Oct 5, 2009.

  1. #1
    I'm working with a template and cannot figure out why spaces are being treated like line breaks in IE. Here's the CSS:

    #main_header #header ul.menu li{
    background:url no-repeat right; height:22px; padding:0 14px 0 5px; margin:0;
    display:block; float:left;
    }

    And the html:

    <li><a href="http://www.example.com/">Home Page</a></li>

    Which displays as "Home Page" in FF but "Home (Line break) Page" in IE.

    I've used this as a workaround:
    <li><a href="http://www.example.com/">Home&nbsp;Page</a></li>

    But seems sloppy. Any ideas?
     
    Phoenixaz, Oct 5, 2009 IP
  2. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #2
    IE generally tends to shrinkwrap aggressively. This is not incorrect. For this reason, it is a good practice to define a width for float elements.

    cheers,

    gary
     
    kk5st, Oct 5, 2009 IP
  3. goliath

    goliath Active Member

    Messages:
    308
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    60
    #3
    Yes, Width is what you need. Also IE and some other broswers handle padding differently. This can create different behaviors.

    In either case, set a fixed width to ensure the element stays wide enough for the text in most browsers.
     
    goliath, Oct 5, 2009 IP
  4. Phoenixaz

    Phoenixaz Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    That took care of the issue. Thanks very much for your help.
     
    Phoenixaz, Oct 6, 2009 IP