Tabs or Spaces: Considering Indentation from an Accessibility Perspective

Tadashi Shigeoka ·  Sun, December 15, 2024

In development, whether to use spaces or tabs for indentation can be considered an eternal debate.

I recently attempted to change indentation to spaces in Change indentation from tabs to spaces · Issue #214 · giselles-ai/giselle.

However, after discovering the article Default to tabs instead of spaces for an ‘accessible first’ environment · Alexander Sandberg, I reconsidered my position.

This article explains why tabs should be the default from an accessibility perspective.

Tabs or Spaces: Benefits of Each

First, let me briefly summarize the benefits of tabs and spaces.

Benefits of Tabs

  • File size: Can represent indentation with a single character, keeping file sizes smaller.
  • Original purpose: Designed specifically to represent indentation.
  • Customizability: Users can customize indent width according to their preferences.

Benefits of Spaces

  • Avoiding environment dependencies: Avoids issues in environments dependent on whitespace characters.
  • Consistency: Always displays the same way, maintaining visual consistency.

The Accessibility Perspective: Why Tabs Matter

While spaces have their merits as shown above, tabs are overwhelmingly superior from an accessibility standpoint.

Consideration for Visually Impaired Users

In Alexander Sandberg’s article, he cites a Reddit post discussing the importance of tabs. Some developers with visual impairments set their tab width to 1 to prevent indentation from becoming too large with bigger font sizes, while others set tab width to 8 to match their monitor environment. This way, using tabs allows for flexible customization of indent width according to each person’s environment.

An Accessible-First Environment

Just as we have the concept of “mobile-first,” we should also consider “accessible-first” in development environments. In other words, it’s important to create an environment where everyone can develop equally. Using tabs is one important element for achieving this.

Why Tabs Should Be the Default

As stated in the article:

“there’s just no counter-argument that even comes close to outweighing the accessibility needs of valued coworkers”

This statement says it all.

By using tabs, indent width can be flexibly adjusted according to individual environments, allowing more people to participate comfortably in development.

Related article: GitHubのコードのタブインデントの表示を調整する方法

Conclusion

This issue attempting to change indentation to spaces became a good opportunity to reconsider the importance of tabs from an accessibility perspective.

I hope to continue developing with accessibility in mind, aiming for an environment where all developers can work comfortably.

That’s all from the Gemba, where we’ve considered indentation and accessibility.