Do browsers remove whitespace in between text of any html tag

Deeptechtons picture Deeptechtons · Jul 22, 2013 · Viewed 23.8k times · Source

Here is a fiddle demonstrating the problem

http://jsfiddle.net/WM8XW/

I have inserted many whitespace in the content of the label tag but the html rendered seems to remove it. Is adding   only solution to the above problem

HTML Content

<label>label with very          long white space in between</label>

Answer

Sirko picture Sirko · Jul 22, 2013

The normal behavior for the display of whitespaces is to compress them into a single one, which is then displayed.

There are two exceptions from that:

  1. The <pre> tag, which keeps the whitespaces as entered.
  2. Setting the CSS property white-space: pre; (respectively pre-wrap or pre-line)