2

Why does the following markup produce a space after each <li></li>, when there are no spaces in the source? If I put them all on one line, the spaces disappear when previewing the page. But why is the browser reading my tabs as spaces?

(You can see a border next to services on the left in the first image. Between that border and services is the space. It's not there in image 2.)

enter image description here

<nav>
    <ul>
        <li><a href="#" class="active">HOME</a></li>
        <li><a href="#">SERVICES</a></li>
        <li><a href="#">PRODUCTS</a></li>
        <li><a href="#">ABOUT</a></li>
        <li><a href="#">CONTACT</a></li>
        <li><a href="#">LIKE US</a></li>
    </ul>
</nav>

Here it is with all tabs removed:

enter image description here

<nav>
    <ul>
        <li><a href="#" class="active">HOME</a></li><li><a href="#">SERVICES</a></li><li><a href="#">PRODUCTS</a></li><li><a href="#">ABOUT</a></li><li><a href="#">CONTACT</a></li><li><a href="#">LIKE US</a></li>
    </ul>
</nav>

EDIT:

Browser is Safari 5.1.5 on OSX Lion. Editor is Espresso. Also tried TextMate. And this is the CSS for the nav.

nav {
    position: relative;
    width: 960px;
    padding: 0 30px;
    background: #281601; /* Old browsers */
    background: -moz-linear-gradient(left,  #3f2c16 0%, #281601 5%, #281601 95%, #3f2c16 100%); /* FF3.6+ */
    background: -webkit-gradient(linear, left top, right top, color-stop(0%,#3f2c16), color-stop(5%,#281601), color-stop(95%,#281601), color-stop(100%,#3f2c16)); /* Chrome,Safari4+ */
    background: -webkit-linear-gradient(left,  #3f2c16 0%,#281601 5%,#281601 95%,#3f2c16 100%); /* Chrome10+,Safari5.1+ */
    background: -o-linear-gradient(left,  #3f2c16 0%,#281601 5%,#281601 95%,#3f2c16 100%); /* Opera 11.10+ */
    background: -ms-linear-gradient(left,  #3f2c16 0%,#281601 5%,#281601 95%,#3f2c16 100%); /* IE10+ */
    background: linear-gradient(left,  #3f2c16 0%,#281601 5%,#281601 95%,#3f2c16 100%); /* W3C */
    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#3f2c16', endColorstr='#3f2c16',GradientType=1 ); /* IE6-9 */
    font-family: 'Crimson Text', serif;
    color: #fff;
}

nav:before {
    position: absolute;
    left: -12px;
    top: 0px;
    content: url('../img/nav-left.png');
}

nav:after {
    position: absolute;
    left: 960px;
    top: 0px;
    content: url('../img/nav-right.png');
}

nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

nav ul li {
    display: inline-block;
}

nav ul li a, nav ul li a:visited {
    display: block;
    color: #c7beb4;
    text-decoration: none;
    font-size: 95%;
    letter-spacing: 0.08em;
    padding: 12px 20px;
    border-right: 1px solid #3b2b18;
}

nav ul li:first-child a:before {
    content: url('../img/nav-icon-home.png');
    margin: 0px 8px 0 0;
}

nav ul li:first-child a:hover:before {
    content: url('../img/nav-icon-home-active.png');
}

nav ul li:last-child {
    float: right;
}

nav ul li:last-child a {
    border:none;
}

nav ul li:last-child a:before {
    content: url('../img/nav-icon-facebook.png');
    margin: 0px 8px 0 0;
}

nav ul li:last-child a:hover:before {
    content: url('../img/nav-icon-facebook-active.png');
}

nav ul li a:hover {
    background: #c7beb4;
    color: #281601;
    box-shadow: inset 0 0 15px rgba(40,22,1,0.5);
}
BoltClock
  • 700,868
  • 160
  • 1,392
  • 1,356
dallen
  • 2,621
  • 7
  • 37
  • 47

1 Answers1

0

Changed li's display to display:table-cell instead of display:inline-block.

dallen
  • 2,621
  • 7
  • 37
  • 47