Welcome to WebmasterWorld Guest from 54.166.46.226

Forum Moderators: not2easy

Message Too Old, No Replies

Strange space after list item

   
5:42 pm on Mar 8, 2011 (gmt 0)

5+ Year Member



Can't quite figure out why I'm getting a margin of around 4 pixels to the left of each list item in this code?


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<title></title>

<style type="text/css">
<!--

.nav-bar ul {
list-style: none;
}

.nav-bar ul li {
display: inline;
}

.nav-bar ul li a {
border-right: 5px solid #000;
} -->
</style>
</head>
<body>
<div class="nav-bar">
<ul>
<li class="list"><a href="#">List</a></li>
<li class="map"><a href="#">Map</a></li>
<li class="grid"><a href="#">Grid</a></li>
</ul>
</div>
</body>
</html>


Any help would be greatly appreciated - I'm sure I'm just being very silly!
6:47 pm on Mar 8, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi there greencode

change display:inline to float:left. ;)

birdbrain
10:57 pm on Mar 8, 2011 (gmt 0)

5+ Year Member



Thanks so much for this. I seem to alternate between floating and displaying! Obviously depending on the rest of the rest of my layout - if I don't use floats should I then just add a display: inline-block; to the ul? So, the final code to read as:


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<title></title>

<style type="text/css">
<!--

.nav-bar ul {
list-style: none;
display: inline-block;
}

.nav-bar ul li {
float: left;
}

.nav-bar ul li a {
border-right: 5px solid #000;
} -->
</style>


</head>
<body>
<div class="nav-bar">
<ul>
<li class="list"><a href="#">List</a></li>
<li class="map"><a href="#">Map</a></li>
<li class="grid"><a href="#">Grid</a></li>
</ul>
</div>
</body>
</html>