Word Wrapping
Another text quality that is inherently presentational is
word wrapping : the way lines break automatically in the browser
window. In CSS, you can prevent lines from wrapping by setting the
white-space
property to nowrap
. The HTML and XHTML Recommendations
define no element for preventing lines from wrapping. However, there are
two nonstandard elements, nobr
and
wbr
, that were introduced by Netscape
and are sometimes used to control whether and where lines wrap.
The nobr
element, which stands
for “no break,” prevents its contents from wrapping. The
wbr
(word break) element allows authors to specify
the preferred point between words at which a line should break. No
hyphen is introduced. These have never been adopted into an HTML
Recommendation, but they are still in use and supported by Internet
Explorer (all versions) and Mozilla. They are not supported in Safari
and Opera.
Text and graphics that appear within the nobr
element always display on one line, and
are not wrapped in the browser window. If the string of characters or
elements within the nobr
element is
very long, it continues off the browser window, and users must scroll
horizontally to the right to see it. Adding a br
within a nobr
element text causes the line to
break.
The esoteric word-break element (wbr
) is used to indicate a recommended word-break point within content if the browser needs to do so. This may be useful if you have long strings of text (such as code or URLs) that may need to fit in tight spaces ...
Get Web Design in a Nutshell, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.