在 html 中,可以使用 css 屬性 margin-bottom 和 margin-top 來調節段落之間的間距:margin-bottom 屬性設置段落底部間距,語法:margin-bottom: [值](例如,margin-bottom: 10px;)margin-top 屬性設置段落頂部間距,語法:margin-top: [值](例如,margin-top: 5%;)
HTML 段落間距調節方法
在 HTML 中,段落之間的間距可以通過 CSS 屬性 margin-bottom
和 margin-top
進行調節。
使用 margin-bottom
屬性
margin-bottom
屬性設置元素底部的外邊距,也就是元素與下方元素之間的間距。語法如下:
<code>margin-bottom: [值];</code>
登錄后復制
其中,值
可以是百分比、像素或其他長度單位。例如,要設置段落底部間距為 10 像素,可以使用以下 CSS 代碼:
<code>p { margin-bottom: 10px; }</code>
登錄后復制
使用 margin-top
屬性
margin-top
屬性設置元素頂部的外邊距,也就是元素與上方元素之間的間距。語法與 margin-bottom
相同:
<code>margin-top: [值];</code>
登錄后復制
例如,要設置段落頂部間距為 5%,可以使用以下 CSS 代碼:
<code>p { margin-top: 5%; }</code>
登錄后復制