Do browsers remove whitespace in between text of any html tag

后端 未结 3 1981
太阳男子
太阳男子 2020-12-06 04:50

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 s

3条回答
  •  广开言路
    2020-12-06 05:27

    Browsers usually treat multiple consecutive spaces and/or carriage returns as a single space. In the case of non-breaking spaces (  or  ) browsers will typically honor multiple consecutive occurrences as-is with no collapsing to a single space.

    Solution1:

    You can hard code the (  or  ) as much as you want.

    Reference

    Any text between the opening

     tag and the closing 
    tag will preserve the formatting of the source document.

    Solution2: You can make use of

     tag.

    Reference

    If you want to execute with css also you can perform the same the above answers are only from html point of view

提交回复
热议问题