The tabSize
property gets and sets the length of
the space used for the tab character.
tabSize |
No | Yes | Yes (MozTabSize) | No | Yes (OTabSize) |
Return the tabSize property:
var v = object.style.tabSize
Set the tabSize property:
object.style.tabSize='number|length|initial|inherit'
Default Value: | 8 |
---|---|
Return Value: | A string representing the tab-size property |
CSS Version | CSS3 |
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: