Click here to get back home

CSS gap between inline elements

 HomeNewsGroups | Search | About
 comp.infosystems.www.authoring.html    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
CSS gap between inline elements DrPanic 02-07-2008
Posted by DrPanic on February 7, 2008, 3:03 am
Please log in for more thread options
Hello.

I have a problem building an horizontal navlist.

The technique i'm using is very simple: a list with inline LI
elements. It works fine but Mozilla render it with a gap between the
LI elements, I can't understand where that gap comes from. IE7 doen't
render it whith that space between inline LI elements.

This is a capture of the problem:

http://img167.imageshack.us/img167/7283/pruebank5.gif

I can fix the problem using float:left in the LI elements but I need
to understand why is Mozilla drawing it whith that gap.

This is the code:

<html>
<head>
<style>

#menu ul {
padding: 0px;
margin: 0px;
list-style: none;
font-weight: bold;
width: 100%;
background-color:yellow;
}

#menu ul li {
display: inline;
border: 1px solid red;
margin:0px;
}

</style>


</head>
<body>
<div id="menu">
<ul>
<li><a href="#">One</a></li>
<li><a href="#">Two</a></li>
<li><a href="#">Three</a></li>
<li><a href="#">Four</a></li>
</ul>
</div>
</body>

¿Can anybody help me?

Thanks a lot.

--
DrPanic EChM#215

Posted by Ben C on February 7, 2008, 3:36 am
Please log in for more thread options
wrote:
> Hello.
>
> I have a problem building an horizontal navlist.
>
> The technique i'm using is very simple: a list with inline LI
> elements. It works fine but Mozilla render it with a gap between the
> LI elements, I can't understand where that gap comes from.

The spec doesn't say exactly how inline boxes are sized-- only that it
should depend on the font in some way.

[...]
> I can fix the problem using float:left in the LI elements but I need
> to understand why is Mozilla drawing it whith that gap.

It looks like it's putting the boxes around the glyphs inside the <li>s,
but around the spaces between them. That's a perfectly reasonable thing
to do.

I would expect the gap, but what IE is doing isn't wrong either.

If you use float, it is well-defined that the boxes should be adjacent.

You can probably get rid of the gap in Firefox if you remove all
whitespace in your source HTML between </li> and <li>.

> This is the code:
>
><html>
><head>
><style>
>
> #menu ul {
> padding: 0px;
> margin: 0px;
> list-style: none;
> font-weight: bold;
> width: 100%;
> background-color:yellow;
> }
>
> #menu ul li {
> display: inline;
> border: 1px solid red;
> margin:0px;
> }
>
></style>
>
>
></head>
><body>
><div id="menu">
><ul>
><li><a href="#">One</a></li>
><li><a href="#">Two</a></li>
><li><a href="#">Three</a></li>
><li><a href="#">Four</a></li>
></ul>
></div>
></body>
>
> ¿Can anybody help me?
>
> Thanks a lot.

Posted by DrPanic on February 10, 2008, 3:31 am
Please log in for more thread options


>It looks like it's putting the boxes around the glyphs inside the <li>s,
>but around the spaces between them. That's a perfectly reasonable thing
>to do.

It works!!

Thak you vey much.

--
DrPanic EChM#215

Posted by C A Upsdell on February 7, 2008, 8:48 am
Please log in for more thread options
DrPanic wrote:
> Hello.
>
> I can fix the problem using float:left in the LI elements but I need
> to understand why is Mozilla drawing it whith that gap.

Using float:left is the correct solution

Posted by Andy Dingley on February 8, 2008, 2:06 pm
Please log in for more thread options

> Using float:left is the correct solution

It's certainly one solution. Is there any concrete reason to favour
either display:inline or float:left for implementing "inline lists" ?
Does this always apply, or is there any context-based reason to favour
one over the other?

Similar ThreadsPosted
Tweaking the style of child elements inline March 1, 2008, 10:59 am
inline frames September 21, 2005, 8:48 pm
inline images December 27, 2005, 2:48 am
display: inline question? April 26, 2008, 1:11 pm
Restricting inline image size March 29, 2005, 6:56 pm
Re: Restricting inline image size March 29, 2005, 9:24 pm
Re: Restricting inline image size March 30, 2005, 2:07 am
Two lines of text in inline context September 1, 2005, 5:40 am
"Glueing" grapchic with inline text together? November 4, 2005, 10:20 am
Showing target of a link inline November 15, 2005, 6:00 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap