W3C home > Mailing lists > Public > www-style@w3.org > December 2012

CSS needs improvements for handling sentence spacing

From: Thomas A. Fine <fine@head.cfa.harvard.edu>
Date: Thu, 20 Dec 2012 15:07:41 -0500
Message-ID: <50D3700D.9020205@head.cfa.harvard.edu>
To: www-style@w3.org
Suppose I have an interest in formatting additional space between 
sentences.  I might want to do this because:
   * I want to approximate the historic norm for published works from 
roughly 1650 to 1950
   * There is some evidence to support that such spacing is helpful for 
new readers, people with certain learning disabilities, and more 
generally people who are speed-reading or scanning.
   * Or just because I find it aesthetically pleasing

The most popularly recommended solution is a non-CSS solution, to use 
the &nbsp entity to add an extra non-collapsing space.  The non-breaking 
space messes up justification where it occurs at line wraps.  Even if 
this is changed to some other space entity, or just a regular space 
together with setting white-space to pre-wrap, this is still not a CSS 
solution, and allows for no fine-grained control.

Unfortunately CSS lacks a reasonable approach for accomplishing this 
seemingly simple feat.  Using the box model on sentence spans does not 
work properly, because space added in the box model is not wrappable 
white space, and as such it messes up justification.

One method does work, but in my opinion is not acceptable.  You can set 
word-spacing to a wide value for your divs or paragraphs, and then reset 
it back to a normal value for every sentence or other contained element. 
  This approach to me seems inverted.  You are effectively setting 
word-spacing to an incorrect value overall and then correcting it 
farther down.  This is confusing and error-prone.

Possible CSS solutions:

#1. If a sentence tag existed, then a "sentence-spacing" parameter could 
be used to adjust sentence spacing wherever two sentences touch.  In the 
absence of such a tag, it could still be possible for a user to specify 
another CSS parameter that describes which spans should be considered 
sentences, e.g. "sentence-span: .sntc" would consider anything of that 
class to be a sentence.

#2. A generic inline spacing parameter could be created for all inline 
elements.  This would be more powerful because you could then customize 
spacing around any phrase or inline image or anything else, but also 
more complicated, as there would have to be some method for two 
connecting elements to negotiate the space between them (e.g. averaging, 
larger one wins, or that it only applies to leading or following space, 
etc.)

#3. If an unambiguous full-stop entity (&fullstop) or unicode character 
existed, this could reliably be used to format sentences.  Alternatively 
this could also be an unambiguous inter-sentence space (&sentencespace).

#4  You could also put a tag only around the white space between 
sentences, and use CSS to control that word-spacing.  This does solve 
the problem of inverting your model that my current word-spacing 
solution would have, but I'm not sure that having a piece of content 
consisting solely of white space makes any sense.

#5. This could be handled through automatic sentence detection. 
Unfortunately these algorithms are not reliable because periods are 
ambiguous, and more generally control is not in the hands of the content 
creator.  On the other hand, it would instantly give sentence spacing 
ability to every existing HTML document with only a single change. 
Also, "period-newline" or "period-space-space" could be used as methods 
of detecting sentences more reliably within the HTML source.

This approach could also be a fallback option within solution #1 above 
(e.g. "sentence-span: auto").  Or alternatively, with automatic sentence 
detection there could be a method of tagging only those things the 
algorithm might get wrong, e.g.  "<NotAFullStop>. </NotAFullStop>"

For the record I prefer a sentence tag or span around actual sentences 
as this has the side-effect of providing semantic information on where 
each sentence starts and ends, and no other solution provides that.

      tom
Received on Thursday, 20 December 2012 20:08:13 GMT

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