是否可以在HTML中插入一个制表符,而不必键入 四次吗?
当前回答
好吧,如果你只需要在一整段的某一行开头有一个很长的空白,那么这可能是一个解决方案:
<span style='display:inline-block;height:1em;width:4em;'> </span>
如果写的内容太多,或者在很多地方都需要这样的制表符,那么您可以这样做
<span class='tab'> </span>
然后将其包含到CSS中:
span.tab {display:inline-block;height:1em;width:4em;}
其他回答
我只想建议:
/* 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:
white-space: pre;
它保留您在HTML中添加的空格,而不是统一它们。
我们可以像这样使用style="white-space:pre":
<p>Text<tab style="white-space:pre"> </tab>: value</p>
<p>Text2<tab style="white-space:pre"> </tab>: value2</p>
<p>Text32<tab style="white-space:pre"> </tab>: value32</p>
里面的空白处填满了制表符,制表符的数量取决于文本。
它看起来是这样的:
Text : value
Text2 : value2
Text32 : value32
如果空格变得如此重要,那么使用预格式化文本和<pre>标记可能会更好。
<head>
<style> t {color:#??????;letter-spacing:35px;} </style>
</head>
<t>.</t>
确保颜色代码与背景相匹配 px可以根据制表符所需的长度变化。
然后在< t >后添加文本。< /t >
句号用作空格符,更容易输入,但'& #160;'也可以用来代替句号,因此颜色编码是不相关的。
<head>
<style> t {letter-spacing:35px;} </style>
</head>
<t> </t>
这主要用于显示文本段落,但在脚本的其他部分也可能有用。