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


当前回答

&ampnbsp单位与字体大小有关。为了理解这种依赖关系,使用CSS/HTML方法考虑em和rem度量单位。

CSS

.tab { margin-left: 1rem; }

HTML

<div class=“tab> ...p and h elements... </div>

显示

1em约等于4 &nbsp;但是,Em unit和&ampnbsp rem unit的显示取决于元素和样式的使用,像这样缩进。

--------h1 indented 1em
--p indented 1em
----h1 indented 1rem
----p indented 1rem

左边距和左填充都有效。在HTML或CSS中没有标签长度单位。可以使用.tab类选择器。

其他回答

只有“pre”标签:

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

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

阿菲克,唯一的办法就是使用

&nbsp;

如果你可以使用CSS,那么你可以使用填充或边距。参看Box模型,而对于ie浏览器,也可参阅ie浏览器的Box模型bug。

下面是HTML提供的插入空白的3种不同方法

类型,要添加单个空格。 类型&ensp;加两个空格。 类型&emsp;加4个空格。

我只想建议:

/* 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>

好吧,如果你只需要在一整段的某一行开头有一个很长的空白,那么这可能是一个解决方案:

<span style='display:inline-block;height:1em;width:4em;'>&nbsp;</span>

如果写的内容太多,或者在很多地方都需要这样的制表符,那么您可以这样做

<span class='tab'>&nbsp;</span>

然后将其包含到CSS中:

span.tab {display:inline-block;height:1em;width:4em;}