CSS tab-size Tutorial

CSS tab-size

The CSS tab-size property is used to specify the width of a tab character. Tabs are commonly used in code snippets and pre-formatted text.

By default, the tab character width is set to 8 spaces in most browsers. You can use the tab-size property to change this default behavior.

Syntax:


        selector {
            tab-size: length;
        }
    

In the syntax above, the selector is the HTML element or class to which you want to apply the tab-size property. The length specifies the width of the tab character in CSS units like pixels or em.

Example:

Result:

            tab-size: 4;
        

This example sets the tab character width to 4 spaces. You can see the difference in tab width below:


            <html>
            <head>
                <title>Example</title>
            </head>
            <body>
                <h1>Hello, World!</h1>
            </body>
            </html>
        

The above code snippet shows a simple HTML document with a tab character width of 4 spaces applied.