Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I create tab indenting in html

Tags:

html

xhtml

I have a situation as follows

<body>
Test<br />
test<br />
test1<br />
</body>

I need to add a tab after the 2nd test and 3rd test

so that it looks similar to this.

Test
    test
        test1

Is there a special HTML entity or special character for TAB. eg. Non-breaking space == & nbsp ;

thanks

like image 337
Elitmiar Avatar asked Jul 01 '09 11:07

Elitmiar


People also ask

Is there an indent tag in HTML?

Spacing and indentation should be consistent throughout your code. Many developers choose to use 4-space or 2-space indentation. In HTML, each nested tag should be indented exactly once inside of its parent tag.

What is the HTML code for indenting paragraphs?

Indent the first line of a paragraph with text-indentPixels (px), em, rem, even percentage (%) units will work. Using a relative unit like percentage will change the amount of indentation based on the width of the webpage.


1 Answers

I am not a fan of using CSS to simulate a Tab Character.
For Indenting, yes, by all means use CSS - but not for Tab Characters.

For a single Tab, I would replace with "&nbsp; &nbsp; " (4 Spaces).
This is similar to what was used to format your Question for display.
The added benefit to this is (if someone copies your text)
   it will preserve the spacing when pasted into Word or Notepad.

Example:

Test<br />
&nbsp; &nbsp; test<br />
&nbsp; &nbsp; &nbsp; &nbsp; test1

Note: If your text is in a <pre> tag, then @Boldewyn's answer is the better option.
Keep in mind, the text in the <pre> tag may render differently than expected.

like image 184
MikeTeeVee Avatar answered Sep 29 '22 12:09

MikeTeeVee