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


当前回答

在CSS中有这个:

span.tab{
    padding: 0 80px; /* Or desired space*/
}

然后在你的HTML有这是你的“长标签”在句子中间,就像我需要的:

<span class="tab"></span>

节省&nbsp;或&emsp;这是你需要的。

其他回答

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

在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

如果你想要这些标签

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

然后使用:

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

把它放在你的CSS中:

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

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

在CSS中有这个:

span.tab{
    padding: 0 80px; /* Or desired space*/
}

然后在你的HTML有这是你的“长标签”在句子中间,就像我需要的:

<span class="tab"></span>

节省&nbsp;或&emsp;这是你需要的。

在段落中插入多个空格(或在段落中间)确实没有什么简单的方法。那些建议你使用CSS的人没有抓住重点。您可能不总是试图从一个侧面缩进一个段落,但实际上,尝试在它的特定位置放置额外的空格。

In essence, in this case, the spaces become the content and not the style. I don't know why so many people don't see that. I guess the rigidity with which they try to enforce the separation of style and content rule (HTML was designed to do both from the beginning - there is nothing wrong with occasionally defining style of an unique element using appropriate tags without having to spend a lot more time on creating CSS style sheets and there is absolutely nothing unreadable about it when it's used in moderation. There is also something to be said for being able to do something quickly.) translates to how they can only consider whitespace characters as being used only for style and indentation.

当没有优雅的方式插入空格,而不必依赖&emsp;和,标签,我认为,如果有一个适当命名的标签,允许您快速插入大量的空格(或者如果,您知道,空格一开始就没有被不必要地消耗),那么结果代码将变得更加不可读。

尽管如此,正如上面所说,您最好的选择是使用&emsp;插入:插入正确的位置