Widely availableSupported across all major browsers. Safe to use in production.

Overview

The tab-size CSS property sets the width of the tab character.

Browser support

Feature Desktop Mobile
Chrome
Edge
Firefox
Safari
Chrome Android
Safari iOS
21
79
91
7
25
7

The CSS data type represents a distance value. Lengths can be used in numerous CSS properties, such as width, height, margin, padding, border-width, font-size, and text-shadow.

42
79
53
13.1
42
13.4
1+Supported (version) Not supported Has note Sub-feature descriptions sourced from MDN Web Docs (CC BY-SA 2.5)
Notes 1 item(s)
Implementation note
  • This property is not yet animatable.
Notes 1 item(s)
Implementation note
  • This property is not yet animatable.
Notes 2 item(s)
Compatibility
  • Available with a vendor prefix: -moz- (4)
Implementation note
  • Before Firefox 53, this property was not animatable.
Notes 1 item(s)
Implementation note
  • This property is not yet animatable.

Syntax

CSS
/* Tab width equal to 4 spaces */
pre {
  tab-size: 4;
  -moz-tab-size: 4; /* For Firefox 91 and earlier */
}

/* Fixed-width specification */
code {
  tab-size: 2em;
}

Live demo

tab-size: 2

tab-size Tab-size: 2 demo.

PreviewFullscreen

tab-size: 4

tab-size Tab-size: 4 demo.

PreviewFullscreen

tab-size: 8

tab-size Tab-size: 8 demo.

PreviewFullscreen

Use cases

  • Using tab-size

    The tab-size CSS property sets the width of the tab character.

Cautions

  • May not be supported in older browsers.

Accessibility

  • Make sure visual changes are conveyed appropriately to assistive technology.

Powered by web-features