Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Text inside div not showing multiple white spaces between words

Tags:

html

css

Div is not showing multiple white spaces in between strings

For Example:

This string 'New Folder' I would like to be displayed as 'New     Folder'

like image 754
deepu Avatar asked May 27 '11 11:05

deepu


People also ask

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   (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.

Why are spaces not showing in HTML?

The source of the problem is that HTML compresses all space characters—tabs, spaces, and carriage returns—to one character. If you want to indent your paragraphs, you can't simply type five spaces and then begin the text.

What entity can provide multiple spaces between text?

The simplest way to add a space in HTML (besides hitting the spacebar) is with the non-breaking space entity, written as   or  . Multiple adjacent non-breaking spaces won't be collapsed by the browser, letting you “force” several visible spaces between words or other page elements.

How do you stop text wrapping in CSS?

If you want to prevent the text from wrapping, you can apply white-space: nowrap; Notice in HTML code example at the top of this article, there are actually two line breaks, one before the line of text and one after, which allow the text to be on its own line (in the code).


1 Answers

That is how html works. Whitespace is collapsed. Look at the way your question is displayed to see an example.

To work around this, wrap your text in a <pre> tag, or use &nbsp; instead of space characters


Or add white-space:pre to the CSS for the div.

like image 117
Ray Avatar answered Oct 13 '22 09:10

Ray