Tab character
A tab character is a control character that encodes alignment instructions in text. Unlike a printable character, it does not represent content like a letter or a digit. Although multiple tab characters have been defined and used in the past, today the variation that is widely used is the horizontal tab (HT). The vertical tab (VT) and other more esoteric alignment control characters were used in the past and remain defined in modern character encodings although rarely used.
Use
[edit]Printing
[edit]Originally, printer mechanisms used mechanical tab stops to indicate where the tabs went. This was done horizontally with movable metal prongs in a row, and vertically with a loop of mylar or other tape the length of a page with holes punched in it to indicate the tab stops. These were manually set to match the pre-printed forms that were loaded into the printer. In practice, settable tab stops were rather quickly replaced with fixed tab stops, de facto standardized at every multiple of eight characters horizontally, and every six lines vertically. A printing program could send zero or more tabs to get to the closest tab stop above and left of where it wanted to print, then send line feeds and spaces to get to the final location. In this sense, a tab character provides for data compression; specifying multiple spaces or lines with a single character.
Text formatting
[edit]The tab character is often used in text to align the left-side of content vertically and in particular to indent paragraphs and lines by an equal amount. In a text editor a (horizontal) tab may be inserted into the content when the tab key is pressed although often the editor can be setup to insert spaces instead of a tab. A word processor supports indentation and tabular formatting, but may or may not use the tab character to encode the formatting. The use of tabs is common for aligning blocks of source code although spaces are a common alternative.
Despite the fact that five characters were the typical paragraph indentation on typewriters, the horizontal tab size of eight evolved because as a power of two it was easier to calculate with the limited digital electronics available.[citation needed] Using this size tab to indent code results in much white space on the left, so most text editors for code, such as IDEs, allow the size of the tab to be changed, and some (in particular on Windows) default to four instead of eight. Disagreements between programmers about what size tabs are correct, and whether to use tabs at all, are common.[1] Modern text editors often use heuristics to adapt to the existing content of a file; inserting tabs or spaces and using tab stop size based on the style of the file content.
Tab-separated values
[edit]The tab-separated values (TSV) data format is often used for exporting and importing tabular data such a database or spreadsheet. Some word processors format pasted TSV data as a table without requiring the user to indicate that they want a table.
Gopher menus use TSV to indicate selectors.
TSV has been cited as a modern approach to solving the programming debate regarding the use of tabs and spaces for code alignment called elastic tabstops.[2] This idea uses a scheme called tab-separated columns (TSC) rather than the similar tab-separated values (TSV).
Representation
[edit]ASCII
[edit]In ASCII, the code has value 9. Since ASCII values were originally typed by holding the Control key and pressing a letter key on a typewriter-style terminal, the tab character is sometimes written as Ctrl +I or ^I.
EBCDIC
[edit]In EBCDIC, the code for HT is 5. VT is 11 (the same as in ASCII).
String literal escape syntax
[edit]In many programming languages, the escape sequence \t represents the tab character in a string literal.
Unicode
[edit]The Unicode code points for the (horizontal) tab character, and the more rarely used vertical tab character are copied from ASCII:[3]
- U+0009 <control-0009> (CHARACTER TABULATION, horizontal tabulation (HT), tab)
- U+000B <control-000B> (LINE TABULATION, vertical tabulation (VT))
The tab characters can be graphically represented by special symbols:
- U+2409 ␉ SYMBOL FOR HORIZONTAL TABULATION
- U+240B ␋ SYMBOL FOR VERTICAL TABULATION
Unicode also has characters for the symbols to represent or be printed on the tab key:[4]
- U+21B9 ↹ LEFTWARDS ARROW TO BAR OVER RIGHTWARDS ARROW TO BAR (tab with shift tab)
- U+21C6 ⇆ LEFTWARDS ARROW OVER RIGHTWARDS ARROW
- U+21E4 ⇤ LEFTWARDS ARROW TO BAR (leftward tab)
- U+21E5 ⇥ RIGHTWARDS ARROW TO BAR (rightward tab)
Unicode provides additional characters for tab symbols with triangle-headed arrow:[5]
- U+2B70 ⭰ LEFTWARDS TRIANGLE-HEADED ARROW TO BAR (left tab)
- U+2B71 ⭱ UPWARDS TRIANGLE-HEADED ARROW TO BAR (up tab)
- U+2B72 ⭲ RIGHTWARDS TRIANGLE-HEADED ARROW TO BAR (right tab)
- U+2B73 ⭳ DOWNWARDS TRIANGLE-HEADED ARROW TO BAR (down tab)
- U+2B7E ⭾ HORIZONTAL TAB KEY
- U+2B7F ⭿ VERTICAL TAB KEY
HTML
[edit]In HTML the horizontal tab is coded using 	 or 	[6][7] but as with all whitespace characters in HTML, this will be displayed as a single space except inside <pre>, <code> tags (or other elements with CSS attribute white-space set to pre).
Here is an example:
- HTML
	This line begins with a single tab. Here	are	some	more	tab	characters	! T.......T.......T.......T.......T.......T.......T.......T
- Inside
<pre>This line begins with a single tab. Here are some more tab characters ! T.......T.......T.......T.......T.......T.......T.......T
- Outside
<pre>This line begins with a single tab. Here are some more tab characters ! T.......T.......T.......T.......T.......T.......T.......T
Notice that the tab at the start of a line is removed outside <pre>, the eight-character spacing, and how a tab stop is skipped if there are more than eight characters since last one.
CSS3 defines tab-size property, which adjusts the number of spaces for the tab character from the default of eight.[8] The latest version of WebKit supports the tab-size property. The Opera web browser supports the -o-tab-size CSS property, the Firefox web browser supports the -moz-tab-size CSS property with the same meaning.[9]
The vertical tab is  but is not allowed in SGML[citation needed]; this includes XML 1.0[10] and HTML.
See also
[edit]- Comma-separated values – Text format for tabular data
References
[edit]- ^ "Tabs versus Spaces". www.jwz.org. Retrieved 2020-06-02.
- ^ Gravgaard, Nick. "Elastic tabstops - a better way to indent and align code". nickgravgaard.com. Retrieved 23 March 2018.
- ^ "C0 Controls and Basic Latin" (PDF). Retrieved 2013-12-13.
- ^ "Arrows – Unicode" (PDF). Retrieved 2013-12-13.
- ^ "Miscellaneous Symbols and Arrows – Unicode" (PDF). Retrieved 2023-08-31.
- ^ See Character encodings in HTML#HTML character references
- ^ "Character Entity Reference Chart". dev.w3.org. Retrieved 23 March 2018.
- ^ "CSS 3 tab-size property W3 specification".
- ^ "CSS tab-size property on Mozilla Developer Network". 21 February 2023.
- ^ "Extensible Markup Language (XML) 1.0" (5th ed.). W3C. 26 November 2008. sec. "Charsets".