Recommended Posts

I am just trying to make the start of a navigation bar. I can't seem to figure out why my boxes have margins inbetween them. I would like them to be touching(no margins). here is the code I have

<html>
<head>
<title>my nav bar</title>
<style type="text/css">

ul { list-style-type: none; }

li { display: inline;
border-style: solid;
border-width: 1px;
padding: 2px;
margin: 0px;}

</style>
<head>

<body>

<ul>
<li>home</li>
<li>hair services</li>
<li>massage</li>
</ul>

</body>
</html>

Link to post
Share on other sites

thanks, that works :-)

Do you know the explanation why it was not working the way I had it? I thought I have seen code examples that made it work with the same style I used.

edit added later//

I think the answer to my question is this. The default behavior is to add a space whenever a newline is started.

Edited by shanenin
Link to post
Share on other sites

I was going to try to explain it, but found someone who had explained it much better:

Every line break in the HTML source (I'm talking about newline character, not <li> or <br> tag) is treated just like a space character. Normally, each <li> is shown on a separate line (block mode), so that implicit space does not have an effect. Your styles sheet overrides the display to inline mode (display:inline), so the implicit space becomes visible.

Second post:

http://www.webmasterworld.com/forum83/3063.htm

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...