是否可以在HTML中插入一个制表符,而不必键入 四次吗?


当前回答

只有“pre”标签:

<pre>Name:      Waleed Hasees
Age:        33y
Address:    Palestine / Jein</pre>

你可以在这个标签上应用任何CSS类。

其他回答

不,就HTML而言,Tab只是空白。我推荐一个这么大的em-space(→| |←)…通常是4个空格宽,输入为&emsp;

如果幸运的话,您甚至可以使用Unicode字符(" ")来表示它。

下面是Unicode中空格字符和“零宽度空格”的列表。

CSS

<html>
<head>
<style>
    tab:before
    {
        content: "\00a0\00a0\00a0\00a0";
    }
</style>
</head>

HTML

<body>
    <tab> #include &lt; stdio.h &gt; <br>
    <tab> <br>
    <tab> int main (void) <br>
    <tab> { <br>
    <tab> <tab> printf ("Hello, World!"); <br>
    <tab> <tab> return 0; <br>
    <tab> } <br>
</body>
</html>

呈现

你还可以使用:

p::before {
    content: "";
    padding-left: 30px;
}

然后用你想到的其他选择器替换p。

如果你想要这些标签

像制表员一样工作,即使是在内容表中 不想用难看的“pre”字体

然后使用:

<pre class='TAB'>&#009;</pre>

把它放在你的CSS中:

.TAB {
margin:0; padding:0;
display:inline;
tab-size: 8;
}

根据需要更改制表符大小。

您可以使用一个表并将width属性应用于第一个<td>。

<table>
    <tr>
        <td width="100">Content1</td>
        <td>Content2</td>
    </tr>
    <tr>
        <td>Content3</td>
        <td>Content4</td>
    </tr>
</table>

结果

Content1       Content2
Content3       Content4