473,395 Members | 1,978 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

White space, collapsing

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
4 3556
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Grumble | last post by:
Hello all, I want to read lines from a text file, where each line has the following syntax: token1:token2:token3 There could be white space between tokens and ':'
2
by: Malcolm Dew-Jones | last post by:
I am looking at xslt 1.0 and trying to understand if empty text nodes are supposed to be stripped or not as the default behaviour. 3.4 starts by listing rules for when white space is not stripped...
17
by: Stanimir Stamenkov | last post by:
Is it possible to make two inline elements to appear adjacent stripping any white space appearing in between in the source? Example: <span class="adj">1</span> <span class="adj">2</span>...
5
by: Applebrown | last post by:
Hello, basically, I'm just learning intermediate CSS and trying to convert my old table webpage completely to CSS. Hoorah, right? Well, it's not quite going as planned. It's an extremely simple...
0
by: Mark Moore | last post by:
I'm trying to layout a couple text input fields and their corresponding labels without using a table. When I was trying to debug my understanding of CSS, I was *very* surprised to see that span's...
3
by: Simon Dean | last post by:
Hello! Im looking to try and get into CSS for formatting my sites. Seems like a nice premise, and should allow easier design for the future. But gees, Im having a hard time of it. I would...
5
by: Michael Shell | last post by:
Greetings, Consider the XHTML document attached at the end of this post. When viewed under Firefox 1.0.5 on Linux, highlighting and pasting (into a text editor) the <pre> tag listing will...
38
by: Xah Lee | last post by:
sometimes i wish to add white space in <p> as to achived effects similar to tab. what should i do? using empty image seems the sure way but rather complicated. (and dosen't change size with...
2
by: shagy | last post by:
Hi, I'm having a problem with a <select><option> which has white space in values... When I post the data I only get the first word (up to the white space). "Testing white space" becomes...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.