Search code examples
javascripthtmlcsscoding-style

What is the difference between using tab and space when we do source code formatting?


When we want to give some formatting to code to make it more readable. We can use both Tab and Space (by pressing space bar on keyboard). Many time I give space manually.

I've some confusions

  • Is there any difference between them?
  • Is using tab better than spaces?
  • Does using space increase the size of document and tab not?
  • Is there any differences between single tab/space and multiple. in terms of page size?
  • Is there any difference on using tab or space in HTML, CSS and Javascript?

Dreamweaver has this option in preferences

enter image description here


Solution

  • Tabs need less characters and are formatted by users (some display as 2, some as 4 spaces), what can make some code look bad on some other environment.

    Spaces consume more KBs but look equal everywhere.

    Good editors have retab-functions to convert those.

    In JS and CSS it does not matter, HTML should not matter, but can in some cases.