Using too many editors in too many environments, tabbed files usually kills my productivity.
Not just because the structure of the indented code, also because most editors are stupid enough to also use tabs beyond the indentation, for instance for carefully aligned initialisation statements.
Changing the tab-size effectively waves good bye to those.
It’s weird (Wiert loves that word) that HTML peeps even argue about tabs versus spaces:
Most people still use HTML for pixel perfect rendering and spaces help getting character perfect rendering of the source code.
I was glad to bump into [WayBack] Jefferson Lima answering this on Stack Overflow:
The Google HTML/CSS Style Guide and the W3School HTML(5) Style Guide recommend 2 spaces.
This article also brings an analysis of the effect of tabs vs spaces in the resulting file size.
Source: [WayBack] html5 – html indenting standard, tab or two spaces? – Stack Overflow
So: use 2 spacec for HTML indent.
It doesn’t really matter in transmitted size (minified compressed transfer difference is ~0% and the usual image bloat is way larger than the HTML anyway – just try www.webbloatscore.com and watch).
References:
- Indent by 2 spaces at a time.
- Don’t use tabs or mix tabs and spaces for indentation.
Source: [WayBack] Google HTML/CSS Style Guide
- Do not add blank lines without a reason.
- For readability, add blank lines to separate large or logical code blocks.
- For readability, add two spaces of indentation. Do not use the tab key.
- Do not use unnecessary blank lines and indentation. It is not necessary to indent every element.
Source: [WayBack] HTML5 Style Guide
Tabs Spaces Saving Raw file size 1403 bytes 1703 bytes 300 bytes/18% Raw file GZipped 327 bytes 332 bytes 5 bytes/1.5% Raw file minified 1199 bytes 1199 bytes 0 bytes/0% Minified & GZipped 312 bytes 312 bytes 0 bytes/0% When minified, it doesn’t matter if tabs or spaces are used, since they are all stripped away.
–jeroen