How to use Custom CSS In HTML
A new class can be created which gives a certain amount of spacing by using the margin-left property. The amount of space could be given by the number of pixels specified in this property. The display property is also set to ‘inline-block’ so that no line-break is added after the element. This allows the space to sit next to text and other elements.
Syntax
.tab {
display: inline-block;
margin-left: value; /* for e.g: value = 40px*/
}
Example: In this example, we are going to implement the above-explained method.
<!DOCTYPE html>
<html>
<head>
<title>
How to insert spaces/tabs in text using HTML/CSS?
</title>
<style>
.tab {
display: inline-block;
margin-left: 40px;
}
</style>
</head>
<body>
<h1 style="color: green">w3wiki</h1>
<b>How to insert spaces/tabs in text using HTML/CSS?</b>
<p>This is a<span class="tab"></span>tab space in the document.</p>
</body>
</html>
Output:
How to insert spaces/tabs in text using HTML and CSS
In this article, we will learn how to add spaces/tabs in text using HTML and CSS. As we know HTML doesn’t support more than one space by default, that’s why we need some extra attributes or CSS to get extra space in between the text.
These are the following approaches by using these we can add spaces/tabs in text:
Table of Content
- Using the HTML Entities
- Using the tab-size property in CSS
- Using Custom CSS