# How do you write multiple spaces in text?

When I try to add multiple spaces in a quote or text, it just appears as one space. For example, I want formatted output from a program on the question, like this:

2 3 5 7 11 13 17 19 23 29

Which should have been:

2**3**5**7**11*13*17*19*23*29

(With the * being the spaces)

The numbers are not formatted correctly. How do you solve this?

Note: You can click this edit link to see the source code of this answer (if you have enough rep).

To create space-honouring text in Markdown you have a number of options.... There are recommended ways, and other supported ways.

You can have <pre>this has 6 spaces</pre> (supported, but not recommended) forces a new paragraph (even if the <pre>...</pre> is embedded within the text sentence/paragraph), and looks like:

this      has 6 spaces
even when embedded.

Alternatively (recommended), if you want to include the formatted text in a paragraph, you can use the 'backtick' quote () (found to the left of the 1 key on US-keyboards) embedded in a paragraph.

Using <code>This is code</code> (supported, not recommended) also works and does not force a paragraph either, even .... when used in a paragraph like that. When you use the backtick it works even with spaces in the text and it can be embedded in a paragraph.

If you want a block of formatted text (Recommended) and even for the text to be syntax highlighted, and processed using markdown, you can indent blocks of text with 4 spaces...

public static final void main(String[] args) {
// This is a formatted comment:
//    i. using spaces to show
//       that spaces are honoured...
System.out.println("Hello World!");
}


The full help for Markdown is here: Editing Help, and it includes links for more details too. The sections are 'collapsed', so click the show more link in each section for... more.

You can use the HTML non-breaking space, &nbsp; (or if you prefer hexadecimal, &#x00A0;). The Wikipedia article says:

In certain formats (such as HTML), it also prevents the “collapsing” of multiple consecutive whitespace characters into a single space.

So for example, the markdown:

 1&nbsp;2&nbsp;3&nbsp;4<br>
1&nbsp;&nbsp;2&nbsp;&nbsp;3&nbsp;&nbsp;&nbsp;4


renders as:

1 2 3 4
1  2  3   4

But since everything outside a <code> or <pre> block is rendered with a proportional-width font, you may find alignment across multiple lines to be tricky; in that case, using <code> blocks is probably your best bet.

Because content is presented using HTML, and HTML condenses whitespace. Click the little question mark icon above the editing area on the right side to get formatting help.

In this particular case it looks like you want to mark a section of your question as preformatted text. The formatting help page has information on how to do that.

• You're right... but there's a way to do it... do you know how? – nhgrif Aug 2 '14 at 22:22
• @nhgrif there are multiple ways to do it depending on what he wants exactly. Instead of listing them all here, I figure he can just read the formatting help. – Dagg Aug 2 '14 at 22:26
• I just read through the entirety of the formatting help. There's not a clear answer in there. I'm presuming there's an HTML way to do it, and I don't know HTML and clearly Manny Meng doesn't either. – nhgrif Aug 3 '14 at 12:19
• Even though the output of your questions is rendered using HTML, the input is not HTML, it's MarkDown... Saying 'it's HTML' is not at all accurate, because, if it was HTML, then you could do things like <span style="font-weight:bold;"> bolded</span> and have things work too. – rolfl Aug 3 '14 at 14:50
• @rolfl, fixed. By "it's," I meant the output. Now it's more explicit. – Dagg Aug 3 '14 at 16:34
• @nhgrif it sounds like you are talking about putting extra spaces anywhere in the body of the post. As the formatting help mentions, a subset of HTML is supported. If you follow the link detailing that subset, you will see that character entities are supported. So &nbsp;` will work, for example. But it seems clear now that the OP was looking to preformat a section of content in this particular case, so that's not relevant. That's why I stayed away from specifics here to begin with. – Dagg Aug 3 '14 at 16:48