Javascript Reference - HTML DOM Style tabSize Property








The tabSize property gets and sets the length of the space used for the tab character.

Browser Support

tabSize No Yes Yes (MozTabSize) No Yes (OTabSize)

Syntax

Return the tabSize property:

var v = object.style.tabSize 

Set the tabSize property:

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

Property Values

number
Default value 8. Set the number of space-characters to display tab-character
length
Specifies the length of a tab-character.




Technical Details

Default Value: 8
Return Value: A string representing the tab-size property
CSS Version CSS3

Example

The following code shows how to set the tabSize of a <pre> element.


<!DOCTYPE html>
<html>
<body>
<!--  w ww  .  jav a  2s. co m-->
<pre id="t1">
I  have  tabs  inside!
tab          tab
</pre>

<button onclick="myFunction()">test</button>

<script>
function myFunction() {
    document.getElementById("t1").style.MozTabSize = "16"; // Code for Firefox
    document.getElementById("t1").style.OTabSize = "16"; // Code for Opera 10.6-12.1
    document.getElementById("t1").style.tabSize = "16";
}
</script>

</body>
</html>

The code above is rendered as follows: