/    Sign up×
Community /Pin to ProfileBookmark

list based menus (space btween inlined li-s)

hi ?
I’m in a small trouble:
While creating a list based horizontal menu I’ve got some strange spaces between <li> elements, all CSS classes are fine and code is fine it seems. I tried several browsers (IE, Opera GRE-based) and all render the same thing. At the same moment I’ve found a website later where this was solved somehow. I even directly copied style and html parts from it but got the same artifact again. At first I thought it was a DTD issue since I’m using XHTML1.1 and the page where the menu renders fine uses HTML4.01, but after I changed the doctype the problem remained.

Here is the site with a correct menu as an example: [URL=http://mp3gain.sourceforge.net]http://mp3gain.sourceforge.net[/URL] – I tried to find any serious difference between this page and mine and I couldn’t…

I’ve already spent 2 hours trying to understand what produces these spaces and have really found nothing. Any suggestion would be great, if not to correct then at least to understand what attribute of which element is causing that.

Here are both versions of my test (xhtml, html and css respectively):

[code=html]
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.1//EN” “http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<title>Untitled Document</title>
<link href=”ultest.css” rel=”stylesheet” type=”text/css” />
</head>
<body>
<ul>
<li><a href=”#” title=””>home</a></li>
<li><a href=”#” title=””>info</a></li>
<li><a href=”#” title=””>downloads</a></li>
<li><a href=”#” title=””>links</a></li>
</ul>
</body>
</html>
[/code]

[code=html]
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN” “http://www.w3.org/TR/html4/loose.dtd”>
<html>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″>
<title>Untitled Document</title>
<link href=”ultest.css” rel=”stylesheet” type=”text/css”>
</head>
<body>
<ul>
<li><a href=”#” title=””>home</a></li>
<li><a href=”#” title=””>info</a></li>
<li><a href=”#” title=””>downloads</a></li>
<li><a href=”#” title=””>links</a></li>
</ul>
</body>
</html>
[/code]

Maybe I exaggerated a little with margin=0 and padding=0 but I simply didn’t know what to do…

[CODE]
li{display:inline; margin:0px; padding:0px;}
ul{border:none; margin:0px; padding:0px;}
a{padding:5px; margin:0px;
border:1px #333333 solid;
text-decoration:none;
font-family:Verdana, Arial, Helvetica, sans-serif;
font-size:10px; font-weight:bold; color:#333333;}
a:active, a:hover {background-color: #CCCCCC;}
[/CODE]

to post a comment
CSS

6 Comments(s)

Copy linkTweet thisAlerts:
@ray326Sep 20.2006 — Have you tried floating them instead of inlining them?
Copy linkTweet thisAlerts:
@XeelauthorSep 20.2006 — yep, that's solved it :o I feel stupid =S

tnx a lot ?

still the interesting question remains how in that website I posted as example they did it with inline?
Copy linkTweet thisAlerts:
@KravvitzSep 20.2006 — You should be aware that text/html should not be used with XHTML 1.1; use application/xhtml+xml instead or switch to XHTML 1.0 Strict. IE (as of IE7) doesn't support application/xhtml+xml. Simply changing the <meta> element [i]does not[/i] work. This needs to be sent in the actual HTTP Response Header.

[url=http://www.hixie.ch/advocacy/xhtml]Sending XHTML as text/html Considered Harmful[/url]

[url=http://keystonewebsites.com/articles/mime_type.php]Serving up XHTML with the correct MIME type[/url]

http://www.w3.org/2003/01/xhtml-mimetype/

http://www.xml.com/pub/a/2003/03/19/dive-into-xml.html

http://www.w3.org/TR/xhtml-media-types/#summary

[url=http://www.greytower.net/archive/articles/xhtmlcontent.html]Content-Typing XHTML[/url]

http://www.dynamicsitesolutions.com/demos/test.xhtml

[url=http://www.sitepoint.com/forums/showthread.php?t=320391]XHTML 1.0 vs XHTML 1.1[/url]
Copy linkTweet thisAlerts:
@XeelauthorSep 20.2006 — agreed, just wanted to test this list issue so did not pay much attention to how well my xhtml was formed ?
Copy linkTweet thisAlerts:
@XeelauthorSep 20.2006 — Yeah, finally! I know what it was with these spaces of mine! :rolleyes:

If you put link text with a simple space at the end (not &nbsp) the spaces between li-s are gone or let's say they stay inside link elements. In other words browsers were dividing links with a default space, that's all. People, someone could just say me that! ?

An example where "buttons" stay together:

[code=html]
<ul>
<li><a href="#" title="">home </a></li>
<li><a href="#" title="">info </a></li>
<li><a href="#" title="">downloads </a></li>
<li><a href="#" title="">links </a></li>
</ul>
[/code]


Btw I remembered why I hated float attribute - you just can forget about same position and dimensions in different browsers with it.
Copy linkTweet thisAlerts:
@KravvitzSep 20.2006 — [url=http://www.dynamicsitesolutions.com/css/layout_techniques/#floats_margins]Floats[/url] are tricky -- partly because browsers don't all handle them the same (the biggest difference is in how IE handles them) and partly because they are conceptually more difficult to understand than other [url=http://www.dynamicsitesolutions.com/css/layout_techniques/]CSS Positioning techniques[/url]. I love them though.

agreed, just wanted to test this list issue so did not pay much attention to how well my xhtml was formed ?[/QUOTE]
×

Success!

Help @Xeel spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...