HighDots Forums  

Re: CSS gap between inline elements

HTML Writing HTML for the Web (comp.infosystems.www.authoring.html)


Discuss Re: CSS gap between inline elements in the HTML forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Ben C
 
Posts: n/a

Default Re: CSS gap between inline elements - 02-10-2008 , 05:38 AM






On 2008-02-09, VK <schools_ring (AT) yahoo (DOT) com> wrote:
[...]
Quote:
function init() {
var message = '';

var menuItem = document.getElementById('Item1');

if (menuItem.nextSibling.nodeType == Node.TEXT_NODE) {
message+= 'The next node after Item 1 is TEXT_NODE\n';
message+= 'It has width of ' +
The first thing is there is obvious bug in your JS here.

Quote:
menuItem.offsetWidth + 'px ' +
'and height of ' +
menuItem.offsetHeight + 'px';
window.alert(message);
You're alerting the width of Item 1, not the width of the next node
after it.

If you change that to menuItem.nextSibling.offsetWidth Firefox gives you
the value "undefined" (so does Opera).

You probably get undefined whenever you try to get offsetWidth on a
#text node, I'm not sure.

[...]
Quote:
ul
li id="Item1">Item 1</li
li id="Item2">Item 2</li
/ul
p>This way on Gecko a pretty-print line break (even without space)
leads to a <strong>displayed</strong> element with its own width,
height and other properties.
But if you look at the displayed page, there is no mystery element with
an approx 45px width between the two Items. And if you fix the bug in
the JavaScript, you will see that the "phantom text node" does not have
an offsetWidth of 45px either.

Yes a space appears between Item1 and Item2 because there is a newline
in the source. This is correct behaviour and comes under whitespace
collapsing, not under what DOM tree you get from what HTML source.

If a browser treats:

<li id="Item1">Item 1</li>
<li id="Item2">Item 2</li>

differently from

<li id="Item1">Item 1</li>
<li id="Item2">Item 2</li>

then the bug is in its whitespace handling, not in whether whitespace
nodes should appear in the DOM tree or not.


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.