50

I can encode a space using   in an HTML document. Is there an equivalent for the tab character?

I'm trying to preload a <textarea> with text that contains tabs, but my CMS removes any tab characters that exist in the HTML code.

TylerH
  • 20,799
  • 66
  • 75
  • 101
Senseful
  • 86,719
  • 67
  • 308
  • 465

4 Answers4

62

After reviewing your edit, the answer is very simply: &#9; :)

700 Software
  • 85,281
  • 83
  • 234
  • 341
  • 1
    Not that simple actually. See my answer below – Fandango68 Apr 24 '15 at 00:12
  • 1
    Actually, it was for the OP. He's using a ` – 700 Software Apr 24 '15 at 12:06
  • No space allowed to encode in html, you mean :) ? xD – Pansoul Nov 29 '18 at 08:46
25

&emsp;, &ensp;, &#8195; or &#8194; can be used.

Read More at W3.org for HTML3

Read More at W3.org for HTML4

shyammakwana.me
  • 5,562
  • 2
  • 29
  • 50
10

The only way to encode a TAB character in pure HTML is to surround it with <pre></pre> tags, which turns your font into a mono-space font like Courier New. There is no specific <tab></tab> like tags in HTML. Don't ask me why.

Place "<textarea> etc" in between the tags.

With all due respect to the above answers, just placing &#9 will not work as HTML will replace it with a space unless it's in-between the PRE tags.

Fandango68
  • 4,461
  • 4
  • 39
  • 74
7

The simple and easy answer is including in CSS.

white-space: pre;