Code indentation spacing standardization


I used Sublime Text for the front end, I had to open some old code and I had a problem with indentation. I saw that it was only to modify the tab size.

I wonder if there is a Tab Size pattern for building a website's HTML. I currently use Tab Size 4.

asked by anonymous 29.07.2014 / 21:14

2 answers


There are several patterns. The most common is the indentation with 4 spaces.

I recommend the Google HTML / CSS Style Guide as default for HTML and CSS .




Indent by 2 spaces at a time. Do not use tabs or mix tabs and   spaces for indentation:

.example {
  color: blue;
29.07.2014 / 21:54

It depends a lot on the coding standards of the application (or the layout as is the case) and the programmer.

Leftists argue for the use of TAB because it is somewhat universal, but this is counter-argued by right-wing advocates of using spaces (typically 4) because TAB is susceptible to the application that interprets it as a "large space ". but the spaces counter-argued with the fact that, programmatically, a TAB occupies less physical space than 4 common spaces.

Most applications define a TAB as somewhere between 2-3cm. Some more, some less.

The least bad thing to do is set up the IDE the way you're used to at least having a comfortable visual experience. If the application does not support, make a regular global replacement before you start and after you finish from one format to another.

29.07.2014 / 21:32