Why do we need to use 2-space indentations?


If the spacing in our HTML documents doesn’t affect the positioning of content on the page, why do we need to use 2-space indentations?


Experienced developers use indentation and vertical spacing to keep their code neat and legible. Highly readable code improves maintainability, aides collaborative efforts and makes for a better developer experience overall.

Within our HTML, consistent indentation should be used to illustrate nesting. For more info, check out this chapter.


You don’t have to use 2 spaces HTML does not care about spacing outside of literals (e.g. quoted text). I particularly dislike spaces because it is not as adaptive as tab spacing. In fact, you can write the entirety of an html document on a single line (though if you do, look for your boss to fire you as soon as you turn it in as complete.) What you must do, is follow the style guide for the people for whom you are working (unless you want to be fired ). If your company says use two spaces, use two spaces. If they say use four spaces, use four spaces. If they tell you to use tab spacing, do it.


funny, and true facts. Thks for sharing it dude!


When using multiple space indentations, is there a way to put those spaces quicker between words? Like, when you are copy/pasting a text in your code, is there a way to space words quicker than going through each words and space them individually??
feeling super noob here

1 Like

You can use a text-editor like Sublime or VS Code and set them to automatically tab with 2 spaces (instead of default tab). I find this feature very useful especially for languages that are strict about spacing syntax and don’t allow any use of tabs.


@toastedpitabread Great! Thanx so much man!