有三種方法可在 html 中縮進(jìn)段落:使用 css 中的 text-indent 屬性、使用 html 縮進(jìn)元素(即
或 )或在某些情況下使用 indent 屬性(但后者并非所有瀏覽器都支持)。
如何在 HTML 中為段落添加兩個(gè)縮進(jìn)
方法 1:使用文本縮進(jìn)屬性
在 CSS 中,可以使用
text-indent
屬性為段落添加縮進(jìn):<code class="html"><style> p { text-indent: 2em; /* 設(shè)置縮進(jìn)為 2 個(gè) em */ } </style> <p>段落內(nèi)容</p></code>登錄后復(fù)制
方法 2:使用 HTML 縮進(jìn)元素
可以使用
<blockquote></blockquote>
或<indent></indent>
元素來創(chuàng)建縮進(jìn)段落:<code class="html"><blockquote cite="出處"> <p>段落內(nèi)容</p> </blockquote> </code>登錄后復(fù)制
或:
<code class="html"><indent><p>段落內(nèi)容</p> </indent></code>登錄后復(fù)制
方法 3:使用 HTML 縮進(jìn)屬性
在某些情況下,可以使用
indent
屬性直接縮進(jìn)段落:<code class="html"><p indent="2">段落內(nèi)容</p></code>登錄后復(fù)制
然而,這個(gè)屬性在所有瀏覽器中都不受支持。