Please enable JavaScript to use CodeHS

CodeHS Glossary


Indentation General

Indentation is the visual structure of your code layout. It uses whitespace, such as spaces or tabs, to organize code into a hierarchy. On CodeHS, you can use spaces (usually 4) or the tab key. However, if the editor flags your indentation or behaves unexpectedly when using tab, you should use spaces manually instead. **How to indent your code** To indent your code, you should insert 4 spaces or the tab key to before a line of code. Using the tab key allows you to indent multiple lines at once. To do this, you should select the code you want to indent and hit: ``` TAB // indents code forward SHIFT+TAB // indents code back ``` **Why is indentation important?** 1. Code that isn’t indented isn’t as easy to read. 2. Indentation is especially important when using multiple loops, functions, and if statements. The indentation gives you a good visual way to see what commands are inside vs. outside of a loop or if statement. 3. Some languages (Python, for example) require code to be indented correctly for it to work. The functionality actually depends on the indentation. This is not the case for Javascript and Java, but it is better to practice good habits.