0 0 Votes

HTML Source: Display multiple Spaces after each other

Question by Guest | 05/01/2014 at 19:51

At the moment, I am working on my first website and unfortunately, I do not have much knowledge about the necessary basics in web design and creating websites looking like you want them to look.

Currently I have a problem with the representation of spaces. When writing a text in the HTML source code, all of the spaces between words are displayed correctly.

But this is only working until writing two spaces behind each other in the source code. Because, when doing so, the only a single space is displayed in the view in the browser. The additional second blank is eliminated. Ironically, it does not matter how many blanks I am writing after each other, there will always be displayed only one in succession in the browser.

I hope my question is not too naive and someone knows an answer. How is it possible to take multiple spaces after each other from the HTML source code to the browser's view?


Stefan Trost

Show Profile | Message
0Best Answer
0 Votes

In fact, in the interpretation of a HTML source code, the browser filters out the entire White Space such as spaces, tabs or line breaks, as long as the White Space does not make a special sense like dividing single words from each other, for example.

Finally, the purpose of HTML is to describe how a website looks like and for example, where a paragraph is placed and not vice versa.

If, for example, each paragraph/line break typed in your source code will also be displayed on the website, it would be hardly possible to format the source possibly halfway reasonable, because you would permanently have to pay attention to the presentation in the browser. The same way it is with the whitespace often used to indent some lines.

To tell the browser that multiple spaces should be shown after each other, you have to tell that in the language of HTML:


Instead of a space, you can also write " " in the source code. " " is a so-called "named character" and represents a nonbreaking space. Correspondingly, several " " connected in series are several consecutive spaces.

In addition to this method, there is another possibility, how to format whole areas that they are displayed in the browser with the same way they are written in the source code. How to do this, I have described in detail in the linked article.
07/01/2014 at 11:50

ReplyPositive Negative

Related Topics

Hide HTML Source Code
Question | 1 Answer

Important Note

Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.


Ask your own question or write your own articles on askingbox.com. How to do.