Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get a tab character?

Tags:

html

In HTML, there is no character for a tab, but I am confused as to why I can copy and paste one here: . (You can't see the full width of it, but if you click to edit my question, you will see the character.) If I can copy and paste a tab character, there should be a unicode equivalent that can be coded into html. I know it doesn't exist, but this is a mystery I've never been able to grasp.

So my question is: why is there not a unicode character for a tab even if I can copy and paste it?

like image 473
Abbey Graebner Avatar asked Mar 12 '12 02:03

Abbey Graebner


People also ask

What is the code for a tab character?

The ASCII code for tab is 09.

What does \t do in HTML?

It is equivalent to the tab character as such. Thus, from the HTML viewpoint, there is no need to “escape” it using the character reference; but you may do so e.g. if your editing program does not let you enter the character conveniently.


1 Answers

Sure there's an entity for tabs:

	 

(The tab is ASCII character 9, or Unicode U+0009.)

However, just like literal tabs (ones you type in to your text editor), all tab characters are treated as whitespace by HTML parsers and collapsed into a single space except those within a <pre> block, where literal tabs will be rendered as 8 spaces in a monospace font.

like image 123
josh3736 Avatar answered Nov 15 '22 23:11

josh3736