Home > Mobile >  How to allow and show extra spaces in html
How to allow and show extra spaces in html

Time:11-03

If I have a web page with the following text:

'This is some (a bunch of extra spaces in here) test print'.

..it will show as 'This is some test print'.

But is there a way to keep extra spaces in there without using 'nbsp;' for them?

CodePudding user response:

Either wrap your text within <pre> tags or set the white-space property to pre

Examples:

p {
  white-space: pre;
}
<p>This is some                                    test print</p>

<pre>This is some                                  test print</pre>
<iframe name="sif1" sandbox="allow-forms allow-modals allow-scripts" frameborder="0"></iframe>

CodePudding user response:

There are various ways

  1. Using special character
&nbsp;
  1. Using pre tag as mentioned by @j08692

  2. using an inline element with the desired width & height without content

  • Related