Groups > Browsers > Opera Browser Beta versions > Re: Inconsistent handling of whitespace in DOM tree




Inconsistent handling of whitespace in DOM tree

Inconsistent handling of whitespace in DOM tree
Mon, 17 Mar 2008 23:58:34 -000
I've noticed a difference in the way Opera handles white space when it  
comes to building a DOM tree. As many people will know, whitespace in  
markup that isn't usually drawn on the screen (such as line breaks and  
tabs in the source between paragraphs) is left out of the DOM tree by IE  
but is added as a text node containing those whitespace characters by  
other browsers like Opera and Firefox, however I've noticed that when it  
comes to tables, Opera behaves like IE and ignores the whitespace between  
cells and rows. I don't know if this is a compatibility thing or just an  
unintentional discrepancy, but would it be worth considering making the  
whitespace in tables handled by Opera 9.5 just like any other element?

This page shows what I mean:
Post Reply
Re: Inconsistent handling of whitespace in DOM tree
Tue, 18 Mar 2008 16:06:51 +120
On Tue, 18 Mar 2008 11:58:34 +1200, Eik <spam@hotmail.com> wrote:

> I've noticed a difference in the way Opera handles white space when it  
> comes to building a DOM tree. As many people will know, whitespace in  
> markup that isn't usually drawn on the screen (such as line breaks and  
> tabs in the source between paragraphs) is left out of the DOM tree by IE  
> but is added as a text node containing those whitespace characters by  
> other browsers like Opera and Firefox, however I've noticed that when it  
> comes to tables, Opera behaves like IE and ignores the whitespace  
> between cells and rows. I don't know if this is a compatibility thing or  
> just an unintentional discrepancy, but would it be worth considering  
> making the whitespace in tables handled by Opera 9.5 just like any other  
> element?
>
> This page shows what I mean:
> http://www.geocities.com/prestocsin/whitespace.html

<bluff type="trying to sound like a DOM expert">
IMO, it is Firefox that is wrong. I would say that whitespace is just a  
special form of text content, and that a node consisting of only  
whitespace should only be created where text content is permitted. Since  
no content nodes are allowed between the <li> elements of a list or the  
cells and rows of a table, no node should be created there. Any visual  
space between the elements of a list or table is a property of the  
elements themselves (margin or border-spacing). Whitespace between the  
elements in markup is merely aesthetic.
I wouldn't want to see any presusre on Microsoft to introduce whitespace  
nodes between table and list elements - it could lead to the  
reintroduction of an IE5 bug where whitespace between </li> <li> in
markup  
was given a height and let to excessive spacing in lists.
</bluff>
Richard
-- 
Post Reply
about | contact