By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,918 Members | 1,923 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,918 IT Pros & Developers. It's quick & easy.

White space, collapsing

P: n/a
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
http://www.unics.uni-hannover.de/nht...ite-space.html
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.

Mar 28 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Andreas Prilop wrote:
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
http://www.unics.uni-hannover.de/nht...ite-space.html
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.


In "painting" the display, the browser determines that the result is
A^^B
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
A^B

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
{white-space:pre}, 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
property.

--

David E. Ross
<http://www.rossde.com/>

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

P: n/a
On Tue, 28 Mar 2006, Andreas Prilop wrote:
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.
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
problem.

So I think you're entitled to expect two spaces.
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.


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...?
Mar 28 '06 #3

P: n/a
On Tue, 28 Mar 2006 17:47:34 +0200, Andreas Prilop
<nh******@rrzn-user.uni-hannover.de> wrote:
How many spaces should be displayed in

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

between "A" and "B"?
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.

I notice that Mozilla displays one space
and Internet Explorer (5 & 6) displays two spaces. See
http://www.unics.uni-hannover.de/nht...ite-space.html
for a cumulative effect.


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

--
Stephen Poley

http://www.xs4all.nl/~sbpoley/webmatters/
Mar 29 '06 #4

P: n/a
To further the education of mankind, Stephen Poley
<sb******************@xs4all.nl> declaimed:
On Tue, 28 Mar 2006 17:47:34 +0200, Andreas Prilop
<nh******@rrzn-user.uni-hannover.de> wrote:
How many spaces should be displayed in

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

between "A" and "B"?


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.

I notice that Mozilla displays one space
and Internet Explorer (5 & 6) displays two spaces. See
http://www.unics.uni-hannover.de/nht...ite-space.html
for a cumulative effect.


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


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
adjacent.

--
Neredbojias
Apprentice Learner
Apr 3 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.