• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

15.1. white-space Property

The white-space property is designed to add extra spaces (i.e., “white space”) between words. It does not function in the same way as word-spacing or letter-spacing do by setting a fixed value that is used to separate the individual letters or words. Instead, it more closely resembles the <pre> HTML tag. The white-space property can take one of three different values: normal, nowrap and, tellingly, pre.

One of the tenets of Web formatting is that you are not normally allowed to have more than one horizontal space separating words in a line. In the days prior to the advent of the word processor, most typists added a couple of spaces between the end of one sentence and the beginning of another. The common form these days is to only have a single space between sentences. Accordingly, whenever somebody adds more than one space between the words in a sentence, the Web browser automatically subtracts them so that only a single space remains. Before the white-space property, Web authors either had the choice of adding multiple non-breaking spaces (“&nbsp;”) between words, or using the <pre> (“preformatted text”) HTML tag. The normal value for white-space simply tells the browser to format a line of text as it normally would by removing excess spaces that appear between words. pre works exactly like the <pre> HTML tag, retaining the original spacing and carriage returns between letters and words on a page. The nowrap ignores any carriage returns, and sets the text as a single, unbroken line, independent of the width of the browser; using this property, you would have to insert a line break (“<br />”) to insert a carriage return. You can see all three properties put to use in Listing 15.1, whose results are depicted in Figure 15-1.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint