This would be a suggestion for the CSS WG but I’m not on that mailing list and before I bother registering and submitting there — tried in the past, failed, I guess must be doing this thing very wrong —, I thought I’d ask for feedback here.
CSS Text Module specifies tab-size with an initial value of 8 (eight). Indeed most if not all browsers seem to render tabulation characters with the width of 8 space characters.
Today, this doesn’t make much sense. The web author reaction to tab-is-eight-spaces is generally WHOA THAT’S WAY TO BIG WHAT HAPPENED?!?
I propose changing the specified initial value to 4.
Why 4?
That seems to be the contemporary de facto standard, the value that most people expect.
A tab-size:4 initial value would be closer to the expectations of both authors and users (wild guess, I know). That would map more closely to the default values used in most code editors, including browser devtools;
Chrome devtools: tab-size:4 in “Edit as HTML” (and more).
Firefox devtools: -moz-tab-size:4 in “Edit as HTML” (and more).
2 is also a common value, but is more like a personal preference that some people use in their code editor of choice.
Gains
Web authors would display code and other types of tab-indented text in <pre> elements without having to convert tab characters to either 2 or 4 spaces because WHOA THAT’S WAY TO BIG WHAT HAPPENED? That would make use of author-specified tab-size optional, rather than mandatory.
View-source views in browsers would be more reasonably indented.
Risks
Breaking some ASCII art that uses tab characters and relies on tab-is-8-spaces.
[Send an email to www-style-request@w3.org with “subscribe” in the subject first. Or click on the “subscribe” link here.]
It’s precisely that breakage that’ll probably make this impossible. People unfortunately mix tabs and spaces together in practice, and expect them to stay aligned.
It’s not difficult to add a * { tab-size: 4; } at the top of your stylesheet. If you use a reset or normalize stylesheet, just throw it in there.
Feel free to file a bug on browsers to use a more reasonable tab-size value for their view-source pages; that doesn’t require any spec changes to fix.
Re. browser tools: looks like Firefox’s updated view-source (in Aurora) now uses tab-size:4. I opened a bug for Chromium.
I still believe web authors would benefit from a tab-size:4 initial value. I’ve witnessed many beginner authors trying to show code online and having to convert tabs to spaces (which they’re often not yet comfortable doing using a code editor) because the default tab-size made their code too wide to show comfortably.
Of course now they could use tab-size:4 themselves, but they would have to know about it and know about current browser support etc., which is unlikely for beginners.
Not a very big use case in the grand scheme of things, but still.
I’ve browsed a few ASCII art galeries with tab-size:40 on, and they seem devoid of tab characters, but of course it might not be representative of actual web content people rely on.
Firefox now uses tab-size:4 in view-source and tab-size:2 in “Edit as HTML” boxes (probably to avoid big indentation in the “Edit as HTML” boxes which are generally not very wide, especially if devtools are docked to the right).
Chrome uses tab-size:4 in their devtools but still the default 8 in view-source (so I opened a bug).
Edge uses 4-space tabs in their Debugger view (which is their new “View Source” view), and 8-space tabs in their “Edit as HTML” view (bug report on Twitter).