homepage Welcome to WebmasterWorld Guest from 54.237.77.181
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / CSS
Forum Library, Charter, Moderator: open

CSS Forum

    
Strange space after list item
greencode




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

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!

 

birdbrain




msg:4278455
 6:47 pm on Mar 8, 2011 (gmt 0)

Hi there greencode

change display:inline to float:left. ;)

birdbrain

greencode




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

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>

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / CSS
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved