Tabs in code blocks should be rendered as four spaces, instead of the default eight, using the tab-size CSS3 property.
Shorter tabs make most languages more readable, especially on smaller screens. Moreover, shortening the tabs would harmonize this feature with the CodeEditor extension, which displays tabs as four spaces and now binds the Tab key to the tab character.
The following rule in MediaWiki core would primarily apply to stylesheets and scripts in the MediaWiki: namespace:
.mw-code { -moz-tab-size: 4; -o-tab-size: 4; tab-size: 4; }
It degrades gracefully in browsers that lack support for the tab-size property. (See http://caniuse.com/css3-tabsize.) Some caveats:
- It doesn't cover Lua modules, because the Scribunto extension doesn't use the mw-code class (it probably should).
- It doesn't match ordinary <pre> blocks. Alternatively, it might make sense to just select .mw-code, pre, and let extensions or individual pages override the rule if necessary.
- The SyntaxHighlight extension seems to convert tabs to eight actual spaces, so this rule would have no effect on <source> tags.
See [[Wikipedia:Village pump (technical)#GeSHi tab size]] for more discussion about this proposal. The Vietnamese Wikipedia has used tab-size for awhile without complaints.