White space, collapsing

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

How many spaces should be displayed in

    A <span style="display:none">x</span> B

between "A" and "B"? I notice that Mozilla displays one space
and Internet Explorer (5 & 6) displays two spaces. See
for a cumulative effect.

Why is this important? Instead of "span", think of the "rp" element
in "Ruby markup": http://ppewww.ph.gla.ac.uk/~flavell/www/umusalu.html
The content of <rp> is usually hidden.

Re: White space, collapsing

Andreas Prilop wrote:
Quoted text here. Click to load it

In "painting" the display, the browser determines that the result is
where the ^ is a blank.  Since white space for languages using Latin
fonts is collapsed to a single instance per the HTML 4.01 specification
section 9.1, this then becomes

Compliance of IE with the HTML specification is quite often lacking.
Thus, I'm not surprised that IE displays two blanks in this case.

A block (e.g., DIV) can have the style property and value
, which prevents the collapsing of white space.
However, the CSS1 specification (section 5.6.2) indicates that a browser
with a "core" implmentation of CSS1 is not required to recognize this


David E. Ross

Concerned about someone (e.g., Pres. Bush) snooping
into your E-mail?  Use PGP.
See my <http://www.rossde.com/PGP/

Re: White space, collapsing

On Tue, 28 Mar 2006, Andreas Prilop wrote:

Quoted text here. Click to load it

Hmmm.  Well, HTML4.01 section 9.1 is clearly relevant.  There seem to
be two possible issues:

1. White space collapse.  But in the *content* we have the "x"
situated between the two spaces, so the spaces are not adjacent in the
*content* (and surely this is what counts?).  While the "x" is not
supposed to be *rendered*, it is still present as part of the
*content*, and I would have thought the HTML rules were supposed to be
applied accordingly, no?

2. White space adjacent to HTML tags.  But this is stated in 9.1 to
affect white space immediately after a start tag, or immediately
before an end tag. HTML says don't rely on them (implying that they
might get suppressed by a browser).

In your example, however, there is neither, so item 2 should't be your

So I think you're entitled to expect two spaces.

Quoted text here. Click to load it

Indeed.  And I got the results that I wanted (both with and without
the fallback behaviour) by taking care whether to put each space
inside or outside of the <rp> markup: example (spaces marked for the
benefit of those reading in monospaced ;-)

<ruby><rb>Rubana-cu </rb>
<rp>[[</rp><rt>dawn-ed</rt><rp>]] </rp></ruby>

In theory, though, either or both of those spaces could be suppressed
by the rules in 9.1 (obviously I'm not talking about the fact that the
second one is *supposed* to be suppressed by the CSS style of
"display:none" which applies to it when CSS is in effect).  No matter
how I juggle them, I can't avoid the spaces coming either directly
after a start tag, or directly before an end tag, and still get the
desired results.

So I suppose in theory I ought to use &nbsp; there...?

Re: White space, collapsing

On Tue, 28 Mar 2006 17:47:34 +0200, Andreas Prilop

Quoted text here. Click to load it

Clearly two spaces: 'x' is a word in HTML terms, and consequently two
spaces should be displayed. A browser in which CSS is disabled should
certainly display two spaces, and I can't see any justification on
enabling CSS to change the (dis)appearance of a character which is not
subject to any CSS styling.

Ahem. Clearly one space: the CSS spec says that an element with
display: none "has no effect on layout" and so the page should be
displayed as if it did not exist.

Quoted text here. Click to load it

Conflict in specs. Neither browser is (or can be) correct, and
consequently both are equally correct.

Stephen Poley

http://www.xs4all.nl/~sbpoley/webmatters /

Re: White space, collapsing

To further the education of mankind, Stephen Poley

Quoted text here. Click to load it

There is no conflict.  If the browser is css-aware and the page has no css,
the "x" is visible and the spaces are not adjacent.  OTOH, if the stated
"display:none;" is so-styled, two spaces are wrong since they would be

Apprentice Learner

Site Timeline