BillyRayPreachersSon
Programmer
I've been scratching my head over this one for a day or so now, gradually removing styling and HTML to try narrow it down.
I've just cracked it, and thought I'd share my findings in case it helps someone else bypass the headache of finding what wasn't completely obvious.
I'm also curious to find out what others think about whether the behaviour should or shouldn't happen - especially so given it is not consistent across browsers.
Enough talk, here's some code:
The code we were using was the first UL example, with no whitespace between the LI elements.
I expected all 3 lists to be 200px wide, with a comma-delimited set of anchors wrapping nicely inside the grey box, never extending out of it. Basically, I've always assumed the comma, being punctuation, would be a valid wrapping point in a string.
What actually happens is completely different.
IE 6
List 1 is extended width-wise to accommodate the LIs.
Lists 2 and 3 wrap as expected.
Safari 3, Safari 4, Chrome
List 1 has 'bluekitten' pushed out of the right-hand end, although 'darkblue' wraps as expected.
Lists 2 and 3 wrap as expected.
IE 7, IE 8, Fx 2, Fx 3, Fx 3.5, Opera 9.63
List 1 has both 'bluekitten' and 'darkblue' pushed out of the right-hand end.
Lists 2 and 3 wrap as expected.
I guess my question is: 'Should the comma always be a valid wrapping point in a string?'
I've always assumed it would be, now I know that that is not always the case.
Dan
Coedit Limited - Delivering standards compliant, accessible web solutions
Dan's Page [blue]@[/blue] Code Couch:
Code Couch Tech Snippets & Info:
I've just cracked it, and thought I'd share my findings in case it helps someone else bypass the headache of finding what wasn't completely obvious.
I'm also curious to find out what others think about whether the behaviour should or shouldn't happen - especially so given it is not consistent across browsers.
Enough talk, here's some code:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml"[/URL] xml:lang="en" lang="en">
<head>
<title>Inline list test</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<style type="text/css">
ul, li {
list-style-type: none;
margin: 0px;
padding: 0px;
}
ul {
background-color: #999999;
width: 200px;
margin-bottom: 10px;
}
li {
display: inline;
}
</style>
</head>
<body>
<ul>
<li><a href="#">nibble</a>,</li><li><a href="#">muppets</a>,</li><li><a href="#">cardoor</a>,</li><li><a href="#">bluekitten</a>,</li><li><a href="#">darkblue</a></li>
</ul>
<ul>
<li><a href="#">nibble</a>,</li> <li><a href="#">muppets</a>,</li> <li><a href="#">cardoor</a>,</li> <li><a href="#">bluekitten</a>,</li> <li><a href="#">darkblue</a></li>
</ul>
<ul>
<li><a href="#">nibble</a>,</li>
<li><a href="#">muppets</a>,</li>
<li><a href="#">cardoor</a>,</li>
<li><a href="#">bluekitten</a>,</li>
<li><a href="#">darkblue</a></li>
</ul>
</body>
</html>
The code we were using was the first UL example, with no whitespace between the LI elements.
I expected all 3 lists to be 200px wide, with a comma-delimited set of anchors wrapping nicely inside the grey box, never extending out of it. Basically, I've always assumed the comma, being punctuation, would be a valid wrapping point in a string.
What actually happens is completely different.
IE 6
List 1 is extended width-wise to accommodate the LIs.
Lists 2 and 3 wrap as expected.
Safari 3, Safari 4, Chrome
List 1 has 'bluekitten' pushed out of the right-hand end, although 'darkblue' wraps as expected.
Lists 2 and 3 wrap as expected.
IE 7, IE 8, Fx 2, Fx 3, Fx 3.5, Opera 9.63
List 1 has both 'bluekitten' and 'darkblue' pushed out of the right-hand end.
Lists 2 and 3 wrap as expected.
I guess my question is: 'Should the comma always be a valid wrapping point in a string?'
I've always assumed it would be, now I know that that is not always the case.
Dan
Coedit Limited - Delivering standards compliant, accessible web solutions
Dan's Page [blue]@[/blue] Code Couch:
Code Couch Tech Snippets & Info: