5

我想在我的字符串中使用制表符空间。我正在提供使用新行的代码。但我不知道如何在字符串中使用制表符空间。谁可以帮我这个事 !?

"Warning ! Sorry Cash Pay is less than this  <br/> month\'s installment. Please pay the  <br/> right amount."
4

4 回答 4

15

&#09;是 ASCII 中的 TAB 字符。但根据 html 规范,所有空白字符都将被剥离为单个字符。还有其他空白字符。喜欢&thinsp;,你&emsp;&ensp;可以试试。

更新

它似乎&emsp;给出了标签大小的间距。请参阅以下内容

  • a&emsp;b呈现为b
  • a&ensp;b呈现为b
  • a&thinsp;b呈现为b
  • a&nbsp;b呈现为b
  • a&#09;b呈现为b
于 2013-01-12T05:04:38.233 回答
0

如果你把你的字符串放在一个 HTML<pre>元素中,那么它可以有一个制表符。"Warning! \t error"要放入 innerHTML 的字符串集<pre id="output"></pre>将导致
: Warning! error

另请参阅:
https ://stackoverflow.com/questions/4631646/how-to-preserve-whitespace-indentation-of-text-enclosed-in-html-pre-tags-exclu

于 2020-07-10T21:22:03.500 回答
0

您还可以使用&nbsp(不间断空格)在 HTML 行中创建空格。

"Warning ! Sorry Cash Pay is less than this &nbsp;&nbsp; month\'s installment. Please pay the  &nbsp; right amount."
于 2021-09-26T05:53:35.510 回答
0

如果要添加单个空格,请键入&nbsp;

如果要添加 2 个空格,请键入&ensp;

如果要添加4个空格,请键入&emsp; (4个空格是一个tab空格)

于 2021-10-20T04:36:48.233 回答