Sent by Jukka K. Korpela on 11 September 2004 22:10
On Fri, 10 Sep 2004, David Leader wrote:
> There was a recent discussion on preventing line breaks at white
> space, but I wondered if there was any way to prevent breaks
> elsewhere.
Despite its name, the white-space property seems to be intended for
affecting line breaks in general. The specifications are far from clear,
but browser practice seems to support the idea that by saying
white-space: nowrap you suggest that no line breaks should appear,
except when explicitly requested for (e.g., by the use of <br> or by an
inner element for which display: block is applied).
> A colleague gave me some text which included the technical
> expression '/cis/-acting' which broke after the first forward slash
> at the end of a line.
On several browsers, it might also be broken after the second slash or
after the hyphen.
Using
<span class="nobr">/cis/-acting</span>
with
..nobr { white-space: nowrap; }
seems to be effective against undesired line breaks.
But I think it's really simpler (and more effective - works when CSS is
off, too) to use the nonstandard <nobr> markup in HTML:
<nobr>/cis/-acting</nobr>
(See http://www.cs.tut.fi/~jkorpela/html/nobr.html )
> I fixed it by editing the text subtly (he probably will not notice),
> but, just for the record, can you do it in css?
So the answer is positive. However, adding the extra markup may take some
time and effort if you really wish to prevent _all_ inappropriate line
breaks and your text contains lots of special notations like codes,
file names, URL, and other strings with special characters. As a
compromise, you might do such things for the most important texts only,
like headings, definitions, and summaries, and hope for the best for the
rest.
(I'm not sure I see what you mean by editing the text. If
you just add or remove words so that a line break occurs elsewhere, it's
unsafe: the column width and the font size may vary (and attempts to
prevent that may cause quite a many problems), and the text might later be
edited by someone who doesn't look out for the effect in formatting.)
--
Jukka "Yucca" Korpela, http://www.cs.tut.fi/~jkorpela/
______________________________________________________________________
css-discuss [EMAIL-REMOVED]]
http://www.css-discuss.org/mailman/listinfo/css-d
List wiki/FAQ -- http://css-discuss.incutio.com/
Supported by evolt.org -- http://www.evolt.org/help_support_evolt/