EN
HTML - how to make two or more spaces inside div
3 points
In this article we would like to show you how to make two or more spaces inside div
element in HTML.
There are three ways to do this:
- By wrapping your text in a
<pre>
tag, - By using
instead of space characters - Non-Breaking Space (check definition here), - By
white-space
style property - CSS.
Check below practical examples.
pre
tag was defined to let display text like plain/text
is diplayed - with keeping tabs, spaces, etc.
xxxxxxxxxx
1
<div>
2
<pre>
3
Both spaces and line breaks
4
will be preserved
5
</pre>
6
<div>
In below example we are using
characters instead of spaces. nbsp
means Non-Breaking Space. Instead
we can use  
quivalent that means same - it is just numerical code.
xxxxxxxxxx
1
<div>Some text<div>
2
<div>
3
Some text 1
4
Some text 2
5
Some text 3
6
<div>
Below example shows how to add inline style to our <div>
tag, so we can use multiple spaces inside it.
Note: that approach keeps new lines and tab characters too.
xxxxxxxxxx
1
<div style="white-space: pre;">Some text</div>
2
<div style="white-space: pre;">
3
Some text 1
4
Some text 2
5
Some text 3
6
</div>
Note: Click here to read more about
white-space
property.