Setting Tab Sizes in HTML with CSS tab-size Property

CSSWeb DevelopmentFront End Technology

CSS tab-size property allows us to set the amount of whitespace used in tabs. The following examples illustrate CSS tab-size property.

Example

 Live Demo

<!DOCTYPE html>
<html>
<head>
<style>
body {
   display: flex;
   flex-direction: column;
}
p {
   white-space: pre;
}
p:last-of-type {
   tab-size: 32;
   -moz-tab-size: 32;
}
</style>
</head>
<body>
<p> Ut sed felis lobortis, fermentum magna vitae, imperdiet lectus.</p>
<p> Ut sed felis lobortis, fermentum magna vitae, imperdiet lectus.</p>
</body>
</html>

Output

This will produce the following result −

Example

 Live Demo

<!DOCTYPE html>
<html>
<head>
<style>
pre {
   margin: 2%;
   box-shadow: inset 0 0 12px lime;
}
p {
   background: lavender;
   tab-size: 1;
   -moz-tab-size: 1;
}
</style>
</head>
<body>
<pre>
4 tabs of size 1 paragraph
.|.|.|.
<p>
Ut sed felis lobortis, fermentum magna vitae, imperdiet lectus.
</p>
</pre>
</body>
</html>

Output

This will produce the following result −

raja
Published on 12-Mar-2021 11:09:31
Advertisements