Philippe Wittenbergh wrote: > On Oct 2, 2007, at 12:36 PM, Michael Leibson wrote: > >> Is there any way to refine the use of {text-align: justify;} so >> that one can, for >> example, prevent the last word of the last line from appearing on >> its own line - like >> this? >> >> Thanks, in advance, for any tips. > > No. Not with CSS 2.1, and not with CSS 3, I think (1).
I'd rather say that it depends. There is no way of saying generally "don't leave the last line on a line of its own" or something like that, but there are different ways of handling this on a case by case basis. > You'll probably need to inject a non-breaking space between the last > to words of your block using Javascript or whatever server side > language is fashionable today. But that is OT. I think you are assuming that the page is dynamically generated. This might or might not be true. On a "static" page (i.e., a page created by a human being directly so that he can control its specific details), it is easy to insert a no-break space, either as such or as the entity reference , e.g. "like this?" This won't help, though, if the last word contains a hyphen, since "like foo-bar?" may result in a line break after the hyphen (on IE and Opera, though not on Firefox). Similar things can be done in CSS, though usually it does not pay off - the no-break space is simpler. But you can write <span class="nobr">like this?</span> with .nobr { white-space: nowrap; } Moreover, this also works if you replace "this" by "foo-bar". Note: In text justification, browsers tend to divide the extra space evenly between words, or (to put it in other words) stretch word spaces evenly. This is not nice for expressions like "1 m" (= one meter) or "1 000" (the way in writing one thousand, English 1,000, in many languages), if considerable stretching will be applied. It is probably better to prevent stretching there, even if it makes other words spaces even wider. And this is where the no-break is helpful: 1 m and 1 000 will each be kept on one line and, moreover, as a matter of common browser practice, will appear with a fixed-width space in them. The latter effect cannot be achieved using CSS. (But this is still relevant to CSS in the sense that it essentially affects how text-align: justify handles the text.) Jukka K. Korpela ("Yucca") http://www.cs.tut.fi/~jkorpela/ ______________________________________________________________________ css-discuss [EMAIL PROTECTED] http://www.css-discuss.org/mailman/listinfo/css-d List wiki/FAQ -- http://css-discuss.incutio.com/ List policies -- http://css-discuss.org/policies.html Supported by evolt.org -- http://www.evolt.org/help_support_evolt/