.

Friday, April 2, 2010

Nonbreaking Spaces

Just as you will want to break some text into discrete chunks, at other times you will
want to keep text together.
For example, you wouldn’t want words separated in dates
(December 25, 2003), awkward phrases that include letters and numbers (24 hours),
or in some company names (“International Business Machine Corporation”).

Suppose you were to use the phrase “12 Angry Men.” You would not want a browser
to split the “12” and “Angry” across two lines, as shown here:

A good example of this technique appears in the movie “12 Angry Men.”

In cases where you do not want the client browser to break text, you should use a nonbreaking
space entity ( ) instead of a normal space.
For example, when coding the "12 Angry Men" paragraph, you would use something
similar to the following code:

<p>A good example of this technique appears in the movie"12&nbsp;Angry&nbsp;Men."</p>

The browser will then be forced to keep the phrase together, treating it as one
cohesive word.

NOTE:Nonbreaking spaces have long been used to force formatting on the client
browser. For example, to indent a line by three spaces, HTML coders would use
something like the following:

&nbsp;&nbsp;&nbsp;Indented by three spaces

Currently have 0 comments:


Leave a Reply