Open In App

HTML | DOM Style tabSize Property

The Style tabSize property in HTML DOM is used to set or return the length of the space used in place of the tab character.

Syntax:



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

Property Values

Example 1: Using “number” property. 






<!DOCTYPE html>
<html>
<head>
    <title>
      DOM Style tabSize Property
    </title>
</head>
<body>
    <h1 style="color: green">
      GeeksforGeeks
    </h1>
    <b>
      DOM Style tabSize Property
    </b>
    <p>
      The tabSize property specifies
      the amount of space to be used
      for the tab character.
    </p>
    <pre id="ts">
     Geeks    For    Geeks
    </pre>
    <button onclick="GFG()">
      Change
    </button>
    <script>
        function GFG() {
            ele = document.getElementById("ts");
            ele.style.tabSize = "16"
        }
    </script>
</body>
</html>

Output:

 

 

Example 2: Using “initial” property. 




<!DOCTYPE html>
<html>
<head>
    <title>
      DOM Style tabSize Property
    </title>
    <style>
      #ts {
          tab-size: 16;
       }
    </style>
</head>
<body>
    <h1 style="color: green">
      GeeksforGeeks
    </h1>
    <b>DOM Style tabSize Property</b>
    <p>
      The tabSize property specifies
      the amount of space to be used
      for the tab character.
    </p>
    <pre id="ts">
      Geeks        For        Geeks
    </pre>
    <button onclick="GFG()">Change</button>
    <script>
        function GFG() {
            ele = document.getElementById("ts");
            ele.style.tabSize = "initial"
        }
    </script>
</body>
</html>

Output:

 

 

Supported Browsers: The browser supported by DOM Style tabSize Property are listed below:


Article Tags :