In computer science, whitespace is any single character or series of characters that represents horizontal or vertical space in typography. When rendered, a whitespace character does not correspond to a visual mark, but typically does occupy an area on a page. For example, the common whitespace symbol " " (the Unicode character at the 32nd code point) represents a blank space, as used between words and sentences in Western scripts.
The term whitespace is based on the assumption that the background color used for rendered text is white, and is thus confusing if it is not.
As is common in technical literature, the two words "white space" have found widespread usage as the single term "whitespace", especially when used as an adjective, as in "whitespace character". Some specifications refer to "white space" while others refer to "whitespace"; there is no difference between the terms, although exactly which characters are being referred to does vary from context to context. For example, in HTML, "whitespace" includes the form feed character, while in XML, "white space" does not.
The most common whitespace characters may be typed via the space bar or the Tab key. Depending on context, a line-break generated by the Return key (Enter key) may be considered whitespace as well.
Runs of whitespace occurring within source code written in computer programming languages are generally ignored; such languages are free-form. But, for example, in Haskell and Python, whitespace and indentation are used for syntactical purposes. And in Whitespace, whitespaces are the only valid characters for programming, while any other characters are ignored.
Still, for most programming languages, abundant use of whitespace, especially trailing whitespace at the end of lines, is considered a nuisance. In interpreted languages, parsing of unnecessary whitespace may affect the speed of execution. In markup languages like HTML, unnecessary whitespace increases the file size, and may so affect the speed of transfer over a network. On the other hand, unnecessary whitespace can also inconspicuously mark code, similar to, but less obvious than comments in code. This can be desirable to prove an infringement of license or copyright that was committed by copying and pasting.
The C language defines whitespace to be "... space, horizontal tab, new-line, vertical tab, and form-feed". The HTTP network protocol has very strict requirements about what type of whitespace can occur in the control structures (such as the header fields) and where it must and must not occur.
On some occasions, such as a textbook on the Modula-2 computer language published ca. 1985 by Springer-Verlag, it is necessary to explicitly show a symbol to indicate a space code. That book, at least, used the symbol ␣ (Unicode U+2423, decimal 9251, OPEN BOX) to show an explicit space code. (In case it doesn't render well on a monitor screen, it's like a ] (closing square bracket) rotated a quarter-turn clockwise, although not as wide, and placed below the writing line. Some fonts render it too narrowly.)
Such usage is similar to multiword file names written for operating systems and applications that are confused by embedded space codes—such file names instead use a low line (_) as a word separator, as_in_this_phrase.
Another such symbol was ␢ (Unicode U+2422, decimal 9250, LATIN SMALL B WITH STROKE). This was used in the early years of computer programming (especially by IBM?) when writing on coding forms. Keypunch operators immediately recognized the symbol as an "explicit space".
[edit] Unicode
- See also: Space (punctuation)#Table of spaces
In Unicode (Unicode Character Database) the following codepoints are defined as whitespace:
- U+0009–U+000D (control characters, containing Tab, CR and LF)
- U+0020 SPACE
- U+0085 NEL (control character next line)
- U+00A0 NBSP (NO-BREAK SPACE)
- U+1680 OGHAM SPACE MARK
- U+180E MONGOLIAN VOWEL SEPARATOR
- U+2000–U+200A (different sorts of spaces)
- U+2028 LS (LINE SEPARATOR)
- U+2029 PS (PARAGRAPH SEPARATOR)
- U+202F NNBSP (NARROW NO-BREAK SPACE)
- U+205F MMSP (MEDIUM MATHEMATICAL SPACE)
- U+3000 IDEOGRAPHIC SPACE