W3C home > Mailing lists > Public > www-style@w3.org > March 2009

Re: [CSS2.1] Yet another white-space issue with anonymous table objects

From: Bert Bos <bert@w3.org>
Date: Tue, 10 Mar 2009 15:57:47 +0100
To: www-style list <www-style@w3.org>
Message-Id: <200903101557.47990.bert@w3.org>
On Monday 09 March 2009, Michael Jansson wrote:
> Although I may not be of much help here, perhaps someone could
> confirm or reject my own understanding of what should go on in this
> case.
>
>     * My first assumption is that the space between the DIVs would
>       reside in an an anonymous block.

I don't know what HTML5 will say, but in HTML4 and XHTML there is no 
white space between the two DIVs. (More precisely: the white space 
isn't significant white space; it just avoids having to write 
impossibly long lines with no spaces.)

So one way to solve Boris's case is to say to authors to stick with 
HTML4, because it typically behaves the way you expect...

But we also have to deal with generic XML. In principle, XML has a 
halfway solution to let authors (or developers of XML-based formats) 
declare which white space is significant and which is only there for 
readability, viz., the "xml:space" attribute. But it is only a halfway 
solution, because its two values "preserve" and "default" mean, 
respectively: "white space is significant," and "it depends on the 
application." Which makes some sense, because an XML editor may want to 
preserve white space even if it isn't significant, but it doesn't solve 
the problem for CSS.

So what to do if an author puts space between two elements in generic 
XML and there is no "xml:space" attribute or it is set to "default"?

The simple solution is to say that all white space is significant and an 
author has to make sure he doesn't put spaces unless he really wants 
them. Or we have to introduce a property that lets the author specify 
which (anonymous) elements have an implicit 'display: none'.

(There is a 'white-space-collapsing: discard' in the Text module, but it 
is not enough. The white space is discarded, but it leaves the box, 
with a zero-width non-joiner inside.)

>     * Second assumption, SGM section 7.6.1 states that leading and
>       trailing blanks should be removed in this block, so the
> anonymous block should in fact be treated as an empty anonymous block
> element.

That is significant in a case like the PRE element, but in this case 
HTML ignores all white space, not just the newlines.

Aside: The PRE case is like this

<pre>
line 1
line 2
line 3
</pre>

In HTML4, this contains two newlines, after line 1 and after line 2. 
After rendering with CSS, that results in a block with three lines. In 
XHTML, however, the rules of XML apply, and thus there are four 
newlines, which results in a CSS block where "line 1" is actually the 
*second* line. That's a disadvantage of XHTML and it means you have to 
write this instead:

<pre>line 1
line 2
line 3
</pre>

> * Third assumption is that empty anonymous block elements 
> should not be rendered (does not have a margin, padding, etc) and
> should thus not affect rendering of any sibling elements.

Collapsing the margins often has this effect visually (if the margins of 
the empty block are small enough), but no boxes are ignored. To ignore 
a box, it has to have 'display' set to 'none'.



Bert
-- 
  Bert Bos                                ( W 3 C ) http://www.w3.org/
  http://www.w3.org/people/bos                               W3C/ERCIM
  bert@w3.org                             2004 Rt des Lucioles / BP 93
  +33 (0)4 92 38 76 92            06902 Sophia Antipolis Cedex, France
Received on Tuesday, 10 March 2009 14:58:24 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:20:17 GMT