中文排版習慣段落首行縮進兩字元,請勿再使用空格( )硬擠。CSS text-indent 專為此設計,語意正確且維護容易。
p {
text-indent: 2em; /* 相對單位,2em = 目前字體大小的 2 倍 */
}
針對所有 <p> 自動生效,乾淨俐落。
.suojin { text-indent: 2em; }
<div class="suojin">
<p>段落一</p>
<p>段落二</p>
<p>段落三</p>
</div>
僅在 .suojin 區塊內的段落生效,彈性更高。
<div style="text-indent:2em">
<p>段落一</p>
<p>段落二</p>
</div>
適合單一區塊臨時需求,無需修改樣式表。
text-indent 僅對區塊級元素(p、div、li 等)有效,<br> 無效。text-indent: -2em 搭配 padding-left: 2em。text-indent: 2ch(ch = 數字 0 寬度),對等寬字體更精確。p 設定 text-indent: 2em。0。margin-bottom 控制段落間距,勿用空行 <p></p>。