Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to insert spaces/tabs in text using HTML/CSS

Possible ways:

<pre> ... </pre> 

or

style="white-space:pre" 

Anything else?

like image 746
Yeseanul Avatar asked Mar 20 '12 18:03

Yeseanul


People also ask

How do you insert a space tab in HTML text?

The &nbsp; character entity used to denote a non-breaking space which is a fixed space. This may be perceived as twice the space of a normal space. It is used to create a space in a line that cannot be broken by word wrap.

How do you put multiple spaces between text in HTML?

Creating extra spaces before or after text To create extra spaces before, after, or in-between your text, use the &nbsp; (non-breaking space) extended HTML character. For example, with the phrasing "extra space" using a double space, we have the following code in our HTML.

How do I add tab space in HTML w3schools?

The tab-size property specifies the width of a tab character. In HTML, the tab character is usually displayed as a single space-character, except for some elements, like <textarea> and <pre>, and the result of the tab-size property will only be visible for those elements.


2 Answers

To insert tab space between two words/sentences I usually use

&emsp; and &ensp;

like image 119
Giri Avatar answered Sep 21 '22 19:09

Giri


In cases wherein the width/height of the space is beyond &nbsp; I usually use:

For horizontal spacer:

<span style="display:inline-block; width: YOURWIDTH;"></span> 

For vertical spacer:

<span style="display:block; height: YOURHEIGHT;"></span> 
like image 27
Japol Avatar answered Sep 21 '22 19:09

Japol