How do I create tab indenting in html

2019-03-19 02:47发布

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

标签: html xhtml
8条回答
你好瞎i
2楼-- · 2019-03-19 03:17

I think that easiest thing to do is to use UL/LI html tags and then to manipulate (and remove if needed) symbols in front of list with CSS.

Then you get something like:

  • Test
  • Test2
    • Test 3

More info + working example you can try out.

查看更多
我只想做你的唯一
3楼-- · 2019-03-19 03:17

See Making a 'Tab' in HTML by Neha Sinha:

Preformatted

You can put tab characters in your HTML directly if you use what’s called “preformatted” text.In HTML, surround text that you want “preformatted” in a pair of “<pre>” and “</pre>” start and end tags.

Tables

You can use a html table so that everything you put within the set of rows(<tr>) and columns(<td>) shows up the same way. You can very well hide the table borders to show the text alone.

Using the <dd> Tag

The <dd> tag is for formatting definitions. But it also will create a line break and make a tab!

&nbsp;, The Non-Breaking Space

One bit of HTML code I used in the table example is the “non-breaking space,” encoded as in HTML. This just gives you some space. Combined with a line break, <br>, you can create some tab-like effects.

Example

Test<br/>
<pre>   </pre>test<br/>
<pre>       </pre>test1<br/>

this should render as:

Test
    test
        test1
查看更多
登录 后发表回答