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


当前回答

理想的CSS代码应该是“display”和“min-width”属性的组合…

display: inline-block;
min-width: 10em; // ...for example, depending on the uniform width to be achieved for the items [in a list], which is a common scenario where tab is often needed.

其他回答

你还可以使用:

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

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

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>

呈现

我只想建议:

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

&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类。