How to set the length of the tab-character with JavaScript?

JavascriptObject Oriented ProgrammingFront End Technology

To set the length of the tab-character, to add more spaces, use the tabSize property. To work it on Firefox, use the MozTabSize property, and set the length of the tab.

Example

You can try to run the following code to return the length of the tab-character with JavaScript −

<!DOCTYPE html>
<html>
   <body>
      <pre id = "t1">
         This is demo text
      </pre>
      <p>Change the tab-size property</p>
      <button onclick = "display()"> Update tab-size </button>
      <script>
          function display() {
            // Works in Firefox
            document.getElementById("t1").style.MozTabSize = "16";
            document.getElementById("t1").style.tabSize = "16";
         }
      </script>
   </body>
</html>
raja
Published on 27-Feb-2018 11:56:48
Advertisements