html – Code indent spacing standardization

Question:

Used Sublime Text for the front-end, I already 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 would like to know if there is a Tab Size pattern for building the HTML of a website. I currently use Tab Size 4.

Answer:

There are several patterns. The most common is the 4-space indentation.

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

Indentation

Indent by 2 spaces at a time. Don't use tabs or mix tabs and spaces for indentation:

<ul>
  <li>Fantastic
  <li>Great
</ul>
.example {
  color: blue;
}
Scroll to Top