Whitespace (computer science)

From Wikipedia, the free encyclopedia

For other uses see Whitespace

In computer science, white space, whitespace, or a whitespace character is any single character which represents horizontal or vertical space in written text, or is a series of such characters.

When rendered, a whitespace character does not correspond to a visual mark, but typically does take up space. 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.

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.

In many 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, which was committed by copying and pasting.

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.

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.

[edit] See also

In other languages