5

I want to use a tab space in my string. I am providing the code of using new line. But I don't know how to use a tab space in a string. Can anyone help me on this !?

"Warning ! Sorry Cash Pay is less than this  <br/> month\'s installment. Please pay the  <br/> right amount."
Shiplu Mokaddim
  • 56,364
  • 17
  • 141
  • 187
Sumon Bappi
  • 1,937
  • 8
  • 38
  • 82

4 Answers4

16

&#09; is TAB character in ASCII. But according to html spec all white space characters will be stripped to a single character. There are other white space characters too. Like &thinsp;, &emsp; and &ensp; You can try them too.

Update

It seems &emsp; gives a spacing of tab size. See the following

  • a&emsp;b rendered as a b
  • a&ensp;b rendered as a b
  • a&thinsp;b rendered as a b
  • a&nbsp;b rendered as a b
  • a&#09;b rendered as a b
Community
  • 1
  • 1
Shiplu Mokaddim
  • 56,364
  • 17
  • 141
  • 187
0

If you put your string in an HTML <pre> element then it can have a tab character. String "Warning! \t error" set to be put into the innerHTML of <pre id="output"></pre> will result in
:Warning! error.

See also:
https://stackoverflow.com/questions/4631646/how-to-preserve-whitespace-indentation-of-text-enclosed-in-html-pre-tags-exclu

Rublacava
  • 414
  • 1
  • 4
  • 16
0

You can also use &nbsp (non-breaking spaces) for making white spaces in HTML lines.

"Warning ! Sorry Cash Pay is less than this &nbsp;&nbsp; month\'s installment. Please pay the  &nbsp; right amount."
m4n0
  • 29,823
  • 27
  • 76
  • 89
0

If you want to add a single space, Type &nbsp;

If you want to add 2 spaces, Type &ensp;

If you want to add 4 spaces, Type &emsp; (4 spaces is a tab space)

Imad Ullah
  • 929
  • 9
  • 17