113

While solving a little bug on a website caused by a non-breaking space ( ) I was wondering if there's an opposite.

Is there an HTML code for a breaking space, and if so, what is it?

I saw mention in this question about a zero-width space (​), but that won't give any width (obviously).

Does an HTML entity exist for a regular space?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Sander Koedood
  • 6,007
  • 6
  • 25
  • 34

5 Answers5

143

  is a regular space (by its numeric ASCII value).

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Bert
  • 2,318
  • 1
  • 12
  • 9
  • 28
    Interesting that this is so sparsely documented vs. ` ` – Rick Davies Mar 31 '20 at 20:14
  • 3
    Is there no named (as opposed to numeric) entity for a regular (breaking) space? Might be easier to remember... – Shawn Dec 15 '20 at 22:11
  • 2
    An entity for a breaking space was probably thought not to be necessary as the simple space character ` ` does it. That and any whitespace in HTML is compacted down into 1 breaking space by default in browsers. My first encounter with something that doesn't behave like this is React's JSX which trims all leading and following spaces, which is why you might need to insert an explicit breaking space. – Rikki Mar 04 '21 at 22:17
  • 1
    There are actually 6 named space entities in HTML. See the answer from @Multicolaure – dthrasher Aug 11 '22 at 05:03
  • Beware! If you have `one\n\ntwo` (here `\n` denotes a newline) and text is rendered as "onetwo", you can't just add ` ` between them, the browser will strip whitespace, even though it is written as an entity. – izogfif Jan 24 '23 at 23:16
14

There are multiple html entities for regular white space, which allow breaking, for instance  

Read this article for more information: https://www.codetd.com/en/article/6915972

Multicolaure
  • 864
  • 8
  • 15
  • 4
    This answer deserves more attention! ` `, ` `, and ` ` are valid named entities for breaking space, at 3 convenient widths. – dthrasher Aug 11 '22 at 05:01
  • This answer could be greatly improved by providing the details directly rather than just linking to an external site. Note: The linked site appears to be down/broken. – Micah Zoltu Jan 29 '23 at 09:40
10

If you are using HTML and you would like more than one space to to appear,   will not work. The unfortunate part about   is it does not wrap properly because it is a non-breaking space.

For those that reached here looking for a solution, try the CSS

white-space: pre-wrap;

This will allow you to have multiple spaces side by side in a single line. It works great for chat programs.

Case
  • 4,244
  • 5
  • 35
  • 53
2

There may be other blank entities (which won't compact to a single) but there is another workaround for doing some padding but still having some wrapping occur as required:

Use the "ZeroWidthSpace" html entity and alternate with either "nbsp" for clarity or simply a space character.

0

I am not sure if this is necessarily the opposite, but you can just use <br/> tag to create a break.

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jun 17 '23 at 07:10