Welcome to the Hindi Tutor QA. Create an account or login for asking a question and writing an answer.
Pooja in Web Designing
Is it possible to insert a tab character in HTML instead of having to type   four times?

3 Answers

0 votes
Nadira
selected
 
Best answer

Below are the 3 different ways provided by HTML to insert empty space

  1. Type   to add a single space.
  2. Type   to add 2 spaces.
  3. Type   to add 4 spaces.
0 votes
Nadira

It depends on which character set you want to use.

There's no tab entity defined in ISO-8859-1 HTML - but there are a couple of whitespace characters other than   such as   ,and  .

In ASCII, 	 is a tab.

0 votes
Nadira

  is the answer.

However, they won't be as functional as you might expect if you are used to using horizontal tabulations in word-processors e.g. Word, Wordperfect, Open Office, Wordworth, etc. They are fixed width, and they cannot be customised.

CSS gives you far greater control and provides an alternative until the W3C provide an official solution.

Example:

padding-left:4em

..or..

margin-left:4em

..as appropriate

It depends on which character set you want to use.

You could set up some tab tags and use them similar to how you would use h tags.

<style>
 tab1 { padding-left: 4em; }
 tab2 { padding-left: 8em; }
 tab3 { padding-left: 12em; }
 tab4 { padding-left: 16em; }
 tab5 { padding-left: 20em; }
 tab6 { padding-left: 24em; }
 tab7 { padding-left: 28em; }
 tab8 { padding-left: 32em; }
 tab9 { padding-left: 36em; }
 tab10 { padding-left: 40em; }
 tab11 { padding-left: 44em; }
 tab12 { padding-left: 48em; }
 tab13 { padding-left: 52em; }
 tab14 { padding-left: 56em; }
 tab15 { padding-left: 60em; }
 tab16 { padding-left: 64em; }
</style>

...and use them like so:

<!DOCTYPE html>
<html>
 <head>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 <title>Tabulation example</title>
 <style type="text/css">
 dummydeclaration { padding-left: 4em; } /* Firefox ignores first declaration for some reason */
 tab1 { padding-left: 4em; }
 tab2 { padding-left: 8em; }
 tab3 { padding-left: 12em; }
 tab4 { padding-left: 16em; }
 tab5 { padding-left: 20em; }
 tab6 { padding-left: 24em; }
 tab7 { padding-left: 28em; }
 tab8 { padding-left: 32em; }
 tab9 { padding-left: 36em; }
 tab10 { padding-left: 40em; }
 tab11 { padding-left: 44em; }
 tab12 { padding-left: 48em; }
 tab13 { padding-left: 52em; }
 tab14 { padding-left: 56em; }
 tab15 { padding-left: 60em; }
 tab16 { padding-left: 64em; }
 </style>
 </head>
 <body>
 <p>Non tabulated text</p>
 <p><tab1>Tabulated text</tab1></p>
 <p><tab2>Tabulated text</tab2></p>
 <p><tab3>Tabulated text</tab3></p>
 <p><tab3>Tabulated text</tab3></p>
 <p><tab2>Tabulated text</tab2></p>
 <p><tab3>Tabulated text</tab3></p>
 <p><tab4>Tabulated text</tab4></p>
 <p><tab4>Tabulated text</tab4></p>
 <p>Non tabulated text</p>
 <p><tab3>Tabulated text</tab3></p>
 <p><tab4>Tabulated text</tab4></p>
 <p><tab4>Tabulated text</tab4></p>
 <p><tab1>Tabulated text</tab1></p>
 <p><tab2>Tabulated text</tab2></p>
 </body>
</html>

Extra discussion

There are no horizontal tabulation entities defined in ISO-8859-1 HTML, however there are some other white-space characters available than the usual &nbsp, for example; &thinsp;&ensp; and the aforementioned &emsp;.

It's also worth mentioning that in ASCII and Unicode, &#09; is a horizontal tabulation.

...