W3C home > Mailing lists > Public > www-dom@w3.org > April to June 1999

Re: RFC: White Space Handling In XML Parsing

From: Steven Champeon <schampeo@hesketh.com>
Date: Thu, 20 May 1999 10:26:33 -0400 (EDT)
To: Arkin <arkin@trendline.co.il>
cc: www-dom@w3.org
Message-ID: <Pine.LNX.3.95.990520100758.19189E-100000@wasabi-eth0-1>
On Thu, 20 May 1999, Arkin wrote:
> See what happens? They all end up the same. HTML does not preserve
> whitespaces by definition expect for the PRE element. By definition (and
> I recommend you pay close attention to the specs), whitespaces are not
> used for formatting in HTML documents, except for the PRE element.

While I agree in principle, due to the paltry state of HTML "Wizzy"
editors, whitespace preservation is essential - not for formatting
the display output, per se, but for maintaining nesting, like so:

<table>
  <tr>
    <td>table cell<br>
    <table>
      <tr>
        <td>nested
        <td>table
        <td>cells
      </tr>
    </table></td>
  </tr>
</table>

Think of source code. Most decent Web designers are forced to.

Also, saying that "all multiple whitespace is reduced to one space"
is different than saying "all unnecessary whitespace is removed". I
can format a link around an image like so:

<a href="http://example.com">
<img src="/images/example.gif">
</a>

and when it displays in the browser, there is a blue underline tail
hanging off the bottom right edge of the graphic, because the whitespace
is reduced to one space, which is then underlined. I must therefore
format the aforementioned thusly:

<a href="http://example.com">
<img src="/images/example.gif"></a><!-- get rid of tail -->

or like so:

<a href="http://example.com"
   target="new_window"
   onClick='do_some_Javascript_stuff();'
   onMouseOver='flip();'
   onMouseOut='flop();'
><img src="/images/example.gif"
      height=10 width=10
      hspace=5 vspace=5
      border=0
></a>

...to achieve more or less the same rendering. Preservation of whitespace
in HTML is more than simply an issue of display, it is an issue of ongoing
maintenance, legibility of markup, and so on. If only the browsers would
let you use SGML comments like you're supposed to be able to:

<a href="http://example.com"
   target="new_window"   -- open this in a new window, per the boss 9/98 --
   onClick='do_stuff();' -- do_stuff() is broken for IE/4.5/Mac. oh, well --
   onMouseOver='flip();' -- stupid mouseover tricks --
   onMouseOut='flop();'  -- more stupid mouseout tricks --
><img src="/images/example.gif"
      height=10 width=10 -- it's 10x10, resized from 14x16. aspect ratios?
                            we don't need to preserve aspect ratios... --
      hspace=5 vspace=5  -- breathing room --
      border=0 -- and get rid of the link border, which affects layout --
></a>

More recent browsers ignore the comments, BTW, but only because they can't
make sense of those such as found above. This, for example, doesn't work:

<P -- ALIGN=CENTER -->
center me! (no, don't!)
</P>

The attribute is parsed anyway, and the content centered.

Cheers,
Steve

-- 
http://dhtml-guis.com         | "You do what you must do
http://hesketh.com/schampeo/  |  and you do it well..."
http://a.jaundicedeye.com     |        - Dylan
Received on Thursday, 20 May 1999 10:26:40 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 22 June 2012 06:13:46 GMT