Set the tabSize of a <pre> element:
document.getElementById("myPRE").style.tabSize = "16";
Click the button to change the tab-size property of the PRE element.
<!DOCTYPE html> <html> <body> <pre id="t1"> I have tabs inside! </pre>/*w ww. j av a2 s .c om*/ <button onclick="myFunction()">Test</button> <script> function myFunction() { document.getElementById("t1").style.MozTabSize = "16"; // Code for Firefox document.getElementById("t1").style.tabSize = "16"; } </script> </body> </html>
The tabSize property specifies the length of the space used for the tab character.
Property Values
Value | Description |
---|---|
number | Default value 8. Sets the number of space-characters to use to show each tab-character |
length | Sets the length of a tab-character. This property value is not supported in any of the major browsers |
initial | Sets this property to its default value. |
inherit | Inherits this property from its parent element. |
The tabSize property returns a String representing the tab-size property of an element.