空白文字とは、コンピュータがテキストを表示するためにレンダリングする際 に、空白を表す文字データ要素のことです。
例えば、スペース文字(U+0020 SPACE、ASCII 32)は、西洋の文字体系における単語区切りなどの空白を表します。
印刷可能な文字はレンダリング時に出力されますが、空白文字は出力されません。空白文字は、テキストのレイアウトを限定的に定義し、隣接する文字の通常のレンダリング順序を中断します。後続の文字の出力は通常、右(右から左に書く場合は左)または次の行の先頭にずれます。連続する複数の空白文字の影響は累積的であり、次の印刷可能な文字は、先行する空白文字の累積的な影響に基づいてレンダリングされる位置になります。
「空白」という用語の由来は、白い紙にテキストを描画するという一般的な慣習にあります。通常、空白文字は白く描画されません。描画には影響を与えますが、空白文字自体は描画されません。

スペース文字は通常、文字とほぼ同じ幅の水平方向の空白を挿入します。等幅フォントの場合、幅は文字の幅と同じで、可変幅フォントの場合はフォントごとに幅が異なります。一部のフォントは、幅の異なる複数のスペース文字をサポートしています。
タブ文字は通常、アプリケーションによって異なるタブストップに基づいて水平方向のスペースを挿入します。
改行文字シーケンスは通常、レンダリング出力位置を次の行の先頭に移動します。テキストの後に続く場合、実際には空白行は生成されません。しかし、テキストブロック間に連続する2つの改行シーケンスがあると、ブロック間に空白行が生成されます。空白行の高さはアプリケーションによって異なります。
空白文字を使ってテキストをレイアウトするのは慣例です。アプリケーションによっては、通常は見えない空白文字を視覚的なマークアップとして表示し、ユーザーがそれを確認できるようにすることがあります。
通常、ユーザーはを押してスペース文字を入力しspacebar、 を押してタブ文字を入力し、 を押して改行を入力します。Tab ↹↵ Enter
以下の表は、Unicode文字データベースで空白文字("WSpace=Y", "WS") として定義されている25文字を示しています。[ 1 ] 17文字は双方向書き込みのアルゴリズム("双方向文字タイプ=WS") と一致する空白の定義を使用しており、「Bidi-WS」文字として知られています。残りの文字も使用できますが、この「Bidi」タイプではありません。
注:以下の表を表示するブラウザやフォントによっては、すべてのスペースが正しく表示されない場合があります。
Unicodeには、視覚的に記号を表示する必要がある場面で、さまざまな空白文字を表すために使用できる可視文字もいくつか用意されています。
"SPC" (analogous to Unicode's single-cell-wide U+2420).[20][21]
Text editors, word processors, and desktop publishing software differ in how they represent whitespace on the screen, and how they represent spaces at the ends of lines longer than the screen or column width. In some cases, spaces are shown simply as blank space; in other cases they may be represented by an interpunct or other symbols. Many different characters (described below) could be used to produce spaces, and non-character functions (such as margins and tab settings) can also affect whitespace.
Many of the Unicode space characters were created for compatibility with classic print typography.[27]
Even if digital typography has algorithmic kerning and justification, those space characters can be used to supplement the electronic formatting when needed.
In computer character encodings, there is a normal general-purpose space (Unicode character U+0020) whose width will vary according to the design of the typeface. Typical values range from 1/5 em to 1/3 em (in digital typography an em is equal to the nominal size of the font, so for a 10-point font the space will probably be between 2 and 3.3 points). Sophisticated fonts may have differently sized spaces for bold, italic, and small-caps faces, and often compositors will manually adjust the width of the space depending on the size and prominence of the text.
In addition to this general-purpose space, it is possible to encode a space of a specific width. See the table above for a complete list.
Em dashes used as parenthetical dividers, and en dashes when used as word joiners, are usually set continuous with the text.[28] However, such a dash can optionally be surrounded with a hair space, U+200A, or thin space, U+2009. The hair space can be written in HTML by using the numeric character references  or  , or the named entity  . The thin space is named entity   and numeric references   or  . These spaces are much thinner than a normal space (except in a monospaced (non-proportional) font), with the hair space in particular being the thinnest of horizontal whitespace characters.
In most programming languagesyntax, whitespace characters can be used to separate tokens. For a free-form language, whitespace characters are ignored by code processors (i.e. compiler). Even when language syntax requires white space, often multiple whitespace characters are treated the same as a single. In an off-side rule language, indentation white space is syntactically significant. In the satirical and contrarian language called Whitespace, whitespace characters are the only significant characters and normal text is ignored.
Good use of white space in source code can group related logic and make the code easier to understand. Excessive use of whitespace, including at the end of a line where it provides no rendering behavior, is considered a nuisance.
Most languages only recognize whitespace characters that have an ASCII code. They disallow most or all of the Unicode codes listed above. The C language defines whitespace characters to be "space, horizontal tab, new-line, vertical tab, and form-feed".[29] The HTTP network protocol requires different types of whitespace to be used in different parts of the protocol; it requires single space characters between items in the status line, a CR/LF pair at the end of a line, and "linear whitespace" in header values.[30]
Typical command-line parsers use the space character to delimitarguments. A value with an embedded space character is problematic since it causes the value to parse as multiple arguments. Typically, a parser allows for escaping the normal argument parsing by enclosing the text in quotes.
If, for example, a user wanted to view the contents of a directory named foo bar by using the ls (list) command, and they did so by entering the command as:
lsfoobar the command would, instead, attempt to list files or directories named foo and bar. The correct syntax would specify only a single argument by enclosing it in double quotes:
ls"foo bar"Or, alternatively, they could choose to leave out the double quotes and instead escape the space with a backslash:
lsfoo\ bar Some markup languages, such as SGML, preserve whitespace as written.
Web markup languages such as XML and HTML treat whitespace characters specially, including space characters, for programmers' convenience. One or more space characters read by conforming display-time processors of those markup languages are collapsed to 0 or 1 space, depending on their semantic context. For example, double (or more) spaces within text are collapsed to a single space, and spaces which appear on either side of the "=" that separates an attribute name from its value have no effect on the interpretation of the document. Element end tags can contain trailing spaces, and empty-element tags in XML can contain spaces before the "/>". In these languages, unnecessary whitespace increases the file size, and so may slow network transfers. On the other hand, unnecessary whitespace can also inconspicuously mark code for identification purposes, in a manner similar to but less overtly obvious than the way comments in code can. This can be of benefit in proving an infringement of license or copyright claim if the code was blatantly copied and pasted.
In XML attribute values, sequences of whitespace characters are treated as a single space when the document is read by a parser.[31] Whitespace in XML element content is not changed in this way by the parser, but an application receiving information from the parser may choose to apply similar rules to element content. An XML document author can use the xml:space="preserve" attribute on an element to instruct the parser to discourage the downstream application from altering whitespace in that element's content.
In most HTML elements, a sequence of whitespace characters is treated as a single inter-word separator, which may manifest as a single space character when rendering text in a language that normally inserts such space between words.[32] Conforming HTML renderers apply literal whitespace behaviour to certain elements: those inside <pre>...</pre> tags, and those where CSS property white-space is set to pre or pre-wrap. In these elements, space characters will not be "collapsed" into inter-word separators.
In MediaWiki markup, as well as the <pre>...</pre> there is an optional <poem>...</poem> tag, which also preserves whitespace. It requires Extension:Poem.[33]
In both XML and HTML, the non-breaking space character, along with other "non-standard" spaces, is not treated as collapsible whitespace.
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 an underscore (_) as a word separator, as_in_this_phrase.
Another such symbol is U+2422␢BLANK SYMBOL, which was used on coding forms in the early years of computer programming. Keypunch operators interpreted it as an "explicit space".[16] It was used in BCDIC,[16]EBCDIC,[16] and ASCII-1963.[16]
The fixed-width space characters (U+2000..U+200A) are derived from conventional (hot lead) typography. Algorithmic kerning and justification in computerized typography do not use these characters. However, where they are used (for example, in typesetting mathematical formulae), their width is generally font-specified, and they typically do not expand during justification. The exception is U+2009 thin space, which sometimes gets adjusted.