The tab-size property

The tab-size property sets the size of the indent created by the Tab key.

Works only if the white-space property is set to pre or pre-wrap, as well as for the pre tag.

The property value takes a positive integer, which specifies the number of white spaces that would be made by the Tab key. Default value: 8 spaces.

Syntax

cssselector {
  tab-size: positive integer;
}

Example

We set the Tab indentation equal to 0 white spaces:

html<div id="elem">
  Lorem ipsum dolor sit amet, consectetur adipiscing elit.
</div>
css#elem {
  tab-size: 0;
  white-space: pre;
  border: 1px solid black;
}

Результат:

Example

We set the Tab indent equal to 1 space:

html<div id="elem">
  Lorem ipsum dolor sit amet, consectetur adipiscing elit.
</div>
css#elem {
  tab-size: 1;
  white-space: pre;
  border: 1px solid black;
}

Результат:

Example

We set the Tab indent equal to 2 spaces:

html<div id="elem">
  Lorem ipsum dolor sit amet, consectetur adipiscing elit.
</div>
css#elem {
  tab-size: 2;
  white-space: pre;
  border: 1px solid black;
}

Результат: