Please enable JavaScript to use CodeHS

CodeHS Glossary


Indentation General

Indentation is the visual structure of how your code is laid out. It uses tabs to organize code into a hierarchy. Having correct indentation is a crucial aspect of programming style. **How to indent your code** Use the tab key to insert a tab before a line of code or use the delete/backspace key to remove a tab. Do not use spaces to indent your code. Using tabs allows you to have a consistent length, and having spaces makes it easy to have code that is misaligned. Mass indentation: Indenting multiple lines at once. Select the code you want to indent and hit ``` TAB // indent code forward SHIFT+TAB // indent 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.