How Many Spaces Is A Tab: 2, 3, 4 or 5?

In Microsoft Word you can control whether or not you want to see the white space characters in your document. This helps to check you haven’t incorrectly inserted a tab where a space should have gone and vice versa.

Generally, a tab is the same width as 4 to 5 spaces provided the font being used equally sizes each character. For example, the Courier font’s tab equals 5 spaces, whereas the Arial font is 11 spaces to each tab when the font size for both is set to 12.

Number of spaces per tab in Courier & Arial fonts

What happens when you increase the font size to 36 for each? The Courier font reduces down to 2 spaces, and the Arial font reduces down to 4 spaces:

As the font size increases, the number of spaces per tab decreases

To see how many spaces per tab for the font being used in Microsoft Word (Mac version), simply go to your Preferences pane and on the View and select the following items:

Show tab and white space characters in Word document

Equally Spaced Characters And Tabs

While the size of a tab in Microsoft Word is dependent on the font size of the characters, how big is a tab when the characters are the same spacing?

This is commonly seen in coding editors for programmers.

In coding there are certain languages such as Python where the indentation is very important, and even if Python isn’t used it helps for readability if your code has indentation.

Sublime Text 3

If you are using some of the popular text editors today, such as Sublime Text, you have a variety of options in the menu panel’s View options to set the number of spaces each tab character will contain, and whether you want the tab character to be converted to spaces.

Here are the options available for setting your tab spacing using the menu:

Sublime Text tab settings – set your tab width to whatever you like, default is 4

Why convert the tab character to spaces?

I have found it helpful to set this option whenever I’m copying and pasting code from my editor to the terminal. I’ve found the tab character can make the pasted code in the terminal look rather weird, and therefore just prefer to convert those tab characters to spaces.

How to see white space characters in Sublime Text?

To see white space characters in your Sublime Text editor you will need to add the following line to your user preferences:

"draw_white_space": "all"

PyCharm

Another popular editor I use is PyCharm, and like Sublime Text you can also view whitespace and set the tab space length.

To enable viewing of the white space character open up the Preferences pane and navigate to Editor > General > Appearance and within this window you should see the option to Show whitespaces :

Show whitespaces in PyCharm

To control the tab width navigate to Editor > Code Style > Python and within this window make sure you’re looking at the Tabs and indents window which will look as follows:

Set the tab size and select whether or not to use the tab character

Python REPL

The Python programming language survives on the correct application of spacing and indentation to users’ code. If there’s one place that could help settle the debate on how many spaces is a tab it would be the Python programming language.

By default, Python comes with a REPL which is an environment where you can test your code.

Here’s a quick snippet of code you can run in the REPL to help determine what Python considers to be the number of spaces a tab is:

>>> print('\t|');print('12345')
    |
12345

And as demonstrated from the REPL it shows that a tab is the equivalent of 4 spaces .

You can read more about how to print tab characters in Python here .

Summary

Coding software such as Sublime Text and PyCharm set the default tab width to 4 spaces and provide the opportunity for the user to convert those tab characters to spaces. Microsoft Word though does not afford this luxury as you are bound to the type of font used as we have shown between the two popular fonts Courier and Arial, and the size of those fonts.

All programs do provide the ability to view your white space characters making it easier to see the type of white space entered.

Photo of author
Ryan Sheehy
Ryan has been dabbling in code since the late '90s when he cut his teeth exploring VBA in Excel. Having his eyes opened with the potential of automating repetitive tasks, he expanded to Python and then moved over to scripting languages such as HTML, CSS, Javascript and PHP.