Sumon Bappi
Sumon Bappi

Reputation: 2019

Tab space in HTML

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."

Upvotes: 5

Views: 31656

Answers (4)

Imad Ullah
Imad Ullah

Reputation: 1218

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)

Upvotes: 0

Madhusha Ravishani
Madhusha Ravishani

Reputation: 41

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."

Upvotes: 0

Rublacava
Rublacava

Reputation: 519

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

Upvotes: 0

Shiplu Mokaddim
Shiplu Mokaddim

Reputation: 57650

&#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

Upvotes: 17

Related Questions