Tabs vs. Spaces: It's an Accessibility Issue

I don't remember where I got my preference for Tabs over Spaces, but I've been ride-or-die Tabs for as long as I can remember. I wasn't joking when I included that "tabs rule, spaces drool" meme in my "Sweat the Small Stuff" article. I run in Team Tabs and while I do try to have "strong opinions weakly held," I am skeptical that anyone would ever be able to change my mind.

Once again for the people in the back: Tabs rule, spaces drool. Change my mind.

This came up in the Aftershow discussion for my podcast many weeks ago, and my friend and co-host Ben Nadel described it as an "accessibility issue," which is just such a perfect description...

The argument goes like this: People are welcome to have their own opinions on how much indentation they would like to see. Perhaps you like 2-character-width indentation, or 8, or somewhere in-between. By using a literal space character for indentation, you are forcing your preference on others who read that code.

Now contrast that with tabs. 1 tab character is 1 level of indentation. If my preference is 2-character-width indentation, that's what I have set in my editor and I see space equivalent to 2 characters. And my teammate who prefers 6 or 8 characters can see it the way they want it.

Now, that's all fine, but here's where it becomes an accessibility issue.

People with less than perfect eyesight can have trouble differentiating indentation when the tab-width is low. For accessibility reasons, we need to be able to see more space. And the more code we're looking at, the more it's needed. Having to scroll down 14 lines of code and keep 6 levels of indentation aligned by eye is so much easier with a wider tab-width.

Nothing against those of you with fantastic vision —I used to be one of you— but when you can get your preference in a way that allows me to also be able to read and understand the code, that is objectively better than an alternative that only lets one of us get what we want or need.

Tabs are just better. It's an accessibility issue.

Addendum

Occasionally I find even more slam-dunk evidence that tabs is the only correct way to indent code, and I've decided that when I do I'm going to add it here.

Thanks to Rich Harris for pointing this one out:

The main reason I would like to see this change is for refreshable braille displays that are used by blind programmers a lot. Each space wastes one braille cell and takes away valuable braille realestate. So if the default indentation of a project is 4 spaces per level, a 3rd level indentation wastes 12 braaille cells before code starts. On a 40 cell display, which is the most commonly used with notebooks, this is more than a quarter of the available cells wasted with no information. If each indentation level was represented by only one tab character, there would be three cells occupied by a tab character each, and on the 4th cell, the code would start. That's less than 10 percent occupied on the same length display, but all cells contain valuable information that is easily discoverable and immediately comprehensible.

MarcoZehe on GitHub in a PR requesting that prettier change their useTabs setting from default false to default true.

Webmentions

It's like comments, but you do it on Twitter.

4 Retweets

sww1235 Chris Moyer 🖖 🭪 🭍🭲🬲 🮫 🬛🬕 🮲🮳 Eoin Prout

27 Replies

Tixie Salander Tixie Salander
And to answer very seriously: no it's not an opinionated thing you should joke about. Why not? Because It's an Accessibility Issue!@adamtuttle described it very rightfully in this post: https://adamtuttle.codes/blog/2021/tabs-vs-spaces-its-an-accessibility-issue Tabs vs. Spaces: It's an Accessibility Issue • Adam Tuttle
Tixie Salander Tixie Salander
And to answer very seriously: no it's not an opinionated thing you should joke about. Why not? Because It's an Accessibility Issue! @AdamTuttle described it very rightfully in this post: adamtuttle.codes/blog/2021/tabs…
Spooky Joran Quinten 🎃🦇👻🐇 Spooky Joran Quinten 🎃🦇👻🐇
As @Rich_Harris figured out: "The main reason I would like to see [tab instead of space] is for refreshable braille displays that are used by blind programmers a lot. Each space wastes one braille cell and takes away valuable braille realestate ..." adamtuttle.codes/blog/2021/tabs…
Niels de Blaauw Niels de Blaauw
I prefer enforcing style rules in CI. The style used locally by developers shouldn't matter. Preferences in tabs vs spaces or tabwidth can be because of accessibility needs. An easy 'fix' command is more valuable. adamtuttle.codes/blog/2021/tabs…
Cristian Molina Cristian Molina
adamtuttle.codes/blog/2021/tabs… Got it!
Smaïne ⚡️ Smaïne ⚡️
Tabs pour des questions d’accessibilité adamtuttle.codes/blog/2021/tabs…
Ramón Huidobro Ramón Huidobro
Found it! adamtuttle.codes/blog/2021/tabs…
Dale Dale
Accessibility? adamtuttle.codes/blog/2021/tabs…
aeris 🏳️‍🌈 aeris 🏳️‍🌈
Ça a été réglé ça : des tabs adamtuttle.codes/blog/2021/tabs…
Matt Wilcox Matt Wilcox
I’ll just wait for you to convert to the more accessibly and friendly tab, good sir. adamtuttle.codes/blog/2021/tabs…
Facundo Facundo
Tabs are objectively better for accessibility adamtuttle.codes/blog/2021/tabs…
Alexander Klink Alexander Klink
adamtuttle.codes/blog/2021/tabs…
Luke Luke
adamtuttle.codes/blog/2021/tabs…
Tom Slutsky Tom Slutsky
adamtuttle.codes/blog/2021/tabs…
Tom Slutsky Tom Slutsky
adamtuttle.codes/blog/2021/tabs… Use tabs. the discussion is over.
Chris Moyer 🖖 Chris Moyer 🖖
Tabs, always. It’s much more accessible: adamtuttle.codes/blog/2021/tabs…
metakuna (9/100 blog posts) metakuna (9/100 blog posts)
no disrespect to The Blind, but I feel like changing the default for everyone just bc tabs work better on braille displays is silly compared to making an IDE extension which display 4 spaces as a tab for braille display users
protect children not guns protect children not guns
"simply do not work" is an awfully bold claim to make when there are thousands upon thousands of us out here doing every single one of those things, using tabs, every day.
dirk l. aus b. dirk l. aus b.
Sorry for the accessibility, but tabs simply do not work for multi language files (javascript + TS + html + JSX) with differing indentations. Also web based merges, diffs, conflicts, pull request do not work as well. This case was closed long ago. nrr
Charles Line Charles Line
Preach, fellow indisputable logic dude.
Chris Moyer 🖖 Chris Moyer 🖖
Ditto. I was appalled when Python decided spaces were the preferred method. In a language where white spaces actually mattered, I have no idea why they would have done such a thing. Now we know it was because they hated a11y 🙄 twitter.com/adamtuttle/sta…
dirk l. aus b. dirk l. aus b.
Any file with different indentation levels at different areas in the file. - Markdown with include code fragments, - React modules with JS, CSS and HTML parts, - default tab is 8. How is a website supposed to display it? How many? Can't change tabsize in a browser.
dirk l. aus b. dirk l. aus b.
It was intentionally bold. Thousands and thousands of yours will degrade quality for millions and millions of others. Sick and tired of this misguided discussions.
Rich Harris Rich Harris
yeah, the braille thing was new information to me too! absolute slam dunk argument IMHO
Add your comment: Tweet about this article.

Webmentions via webmention.io.

Discuss on TwitterEdit on GitHubContributions