Style tabSize attribute

Definition and usage

tabSize The attribute specifies the length of the spaces used for tabs.

In HTML, tabs are usually displayed as a single space character, except for some elements such as <textarea> and <pre>, and the result of the tabSize attribute will only be visible for these elements.

See also:

CSS Reference Manual:tab-size attribute

Example

Set the tabSize of the <pre> element:

document.getElementById("myPRE").style.tabSize = "16";

Try it yourself

Syntax

Return tabSize attribute:

object.style.tabSize

Set tabSize attribute:

object.style.tabSize = "number|length|initial|inherit"

Attribute value

Value Description
number Default value 8. Specifies the number of space characters that each tab should display.
length Specifies the length of the spaces used for tabs. This attribute value is not supported by any mainstream browser.
initial Sets this attribute to its default value. See initial.
inherit Inherits this attribute from its parent element. See inherit.

Technical details

Default value: 8
Return value: A string that represents the tab-size attribute.
CSS version: CSS3

Browser support

The numbers in the table indicate the first browser version that fully supports this attribute.

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Supported 79.0 Not Supported
Please Use
MozTabSize
6.1 15.0