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


当前回答

使用CSS更简洁。试试padding-left:5em或margin-left:5em。

其他回答

我只想建议:

/* In your CSS code: */
pre
{
    display:inline;
}

<!-- And then, in your HTML code: -->

<pre>    This text comes after four spaces.</pre>
<span> Continue the line with other element without braking </span>

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>

呈现

这取决于您想要使用的字符集。

在ISO-8859-1 HTML中没有定义制表符实体,但是除了&nbsp;如&thinsp;, & enp;和&emsp;。

在ASCII中,&#09;是一个标签。

以下是Wikipedia上HTML实体的完整列表和关于空格的有用讨论。

您可以使用一个表并将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
<span style="margin-left:64px"></span>  

可以这样考虑:一个制表符等于64个像素。这就是我们用CSS给出的空间。