How do I make it so tabs are used instead of spaces when TAB is pressed? I've tried setting indent-tabs-mode to t but no dice.

On my other modes, such as php-mode and c-mode, tabs are inserted. CSS mode seems to be ignoring.

God I hate spaces so much.

2 Answers 2


The built-in CSS mode should support this just fine by giving indent-tabs-mode a non-nil value.

Note that spaces will still be used for padding if the number of indentation spaces isn't a multiple of tab-width. The default values of tab-width and css-indent-offset are 8 and 4 respectively, so you'll need two levels of indentation before a tab is inserted.

I think what you want in this case is to set tab-width and css-indent-offset to the same value.

  • 1
    (setq indent-tabs-mode t), (setq tab-width 4), and (setq css-indent-offset 4) work. This applies to new typing. If four spaces are already there, pressing the TAB key does not change the four spaces to one TAB. Also, indent-tabs-mode is a variable in C source code. (add-hook 'css-mode-hook '(lambda () (setq indent-tabs-mode t) (setq tab-width 4) (setq css-indent-offset 4))) in .emacs makes it buffer-local. (See \C-h v.)
    – chan1142
    Apr 8, 2021 at 13:45

You might be out of luck with the built-in css-mode.el. There does not seem to be anything in the package code that allows using tab characters for indentation.

If you collaborate writing code, you are facing an uphill struggle as most people try to avoid tabs like plague. :)

However, EmacsWiki has (old) code for an other css-mode.el that has customisable variable css-tab-mode. Its effect is explained in function css-tab-function. You could try if its other features are good enough for you.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.