Reputation: 559
What is a good way to put more than one space in HTML?
To show one space we write
. For five spaces, we have to write
five times, and so on.
Is there a better way? Is there a special tag to use?
Upvotes: 7
Views: 7199
Reputation: 7066
As far as I know, if you are not using CSS then
is the only way. These days using CSS and adding a spacer <span>
would be more advisable.
Upvotes: 2
Reputation: 3187
It is often best to handle this with CSS instead of HTML. CSS gives you more control over the whitespace than the <pre>
tag does. Also, browsers apply default styles to <pre>
that you might not want.
.pre {
white-space: pre;
}
.pre-wrap {
white-space: pre-wrap;
}
body {
max-width: 12em;
}
<div class="pre">Text that preserves whitespace and does not wrap</div>
<div class="pre-wrap">Text that preserves whitespace and wraps as needed</div>
<pre>Text inside a <pre> tag also preserves whitespace</pre>
Upvotes: 1
Reputation: 835
You can use the
<pre>a text with multiple spaces</pre>
tag.
Upvotes: 8
Reputation:
The simplest way I have used is to add <span style="color:white;">(anything here)</span>
The bit in the span can be as long or as short as you like- it's not seen. The color of course is the color of the page/section where you place it. I prefer XXXXXXX as X is standard width (unlike M and I) and it's easy to see how many Xs you will need for a given space.
Upvotes: -1
Reputation: 1198
To actually insert spaces you are stuck with , the other common thing for spacing things out is to use 1x1 pixel gif and set the images with in the IMG tag.
Upvotes: -1
Reputation: 11824
You could use something like <span style="margin-left: 20px;"></span>
to create some sort of 20px space between two words. Other than that, no.
Upvotes: 1