|This article needs additional citations for verification. (March 2010)|
|Look up indentation in Wiktionary, the free dictionary.|
An indentation may refer to:
- A notch, or deep recess; for instance in a coastline, or a carving in rock
- The placement of text farther to the right to separate it from surrounding text.
For an example of the second meaning, this is an indentation of one non-breaking space:
Indented block because this is something
and this is an indentation of two non-breaking spaces:
Indented block 2
Outdentation is a neologism used in computer circles to describe placing text back to the left again.
Indentation in typesetting
There are two main types of first-line indent: normal and hanging. A "normal" indent indents the first line, as shown here, an indent of one centimeter:
The other kind, a hanging indent, indents the rest of the text while leaving the first line in place; as shown here with a hanging indent of one centimeter:
Indentation in programming
In computer programming languages, indentation is used to format program source code to improve readability. Indentation is generally only of use to programmers; compilers and interpreters rarely care how much whitespace is present in between programming statements. However, certain programming languages rely on the use of indentation to demarcate programming structure, often using a variation of the off-side rule. The Haskell, Occam, and Python programming languages rely on indentation in this way.
Debates over where to indent, whether to use spaces or tabs, and how many spaces to use are often hotly debated among programmers, leading some to classify indentation as akin to a religious war. Different indentation styles are commonly used. In 2006 a third method of indentation was proposed, called elastic tabstops.
|C#||4||As per Microsoft's C# Coding Conventions|
|CSS||Varies||Google, GitHub and Drupal uses 2 spaces.|
|Go||Tabs||As per http://golang.org/doc/effective_go.html|
|Haskell||?||Google uses 2 spaces.|
|HTML||Varies||Google uses 2 spaces. HTML Tidy defaults to 2 spaces.|
|Java||4||Oracle says four spaces. Android uses four spaces.|
|Perl||4||As per Perl style guide|
|PHP||Varies||Drupal use 2 spaces. PEAR and Zend uses 4 spaces. CodeIgniter and WordPress uses tabs. PSR-3 specifies 4 spaces.|
|Python||4||As per PEP-8|
|Visual Basic||4||As per Microsoft's Visual Basic Coding Conventions|
Notes and references
- Tabs versus Spaces: An Eternal Holy War.