<hr> 語意上代表主題分隔,預設樣式單調。透過 CSS border-top 可輕鬆打造虛線、雙線、立體等多樣風格,且相容性極佳。
border: none;height: 2px;border-top 定義線條樣式、顏色| 名稱 | CSS | 效果說明 |
|---|---|---|
| 虛線 | height:2px; border:none; border-top:2px dotted #185598; | 圓點狀虛線 |
| 破折線 | height:1px; border:none; border-top:1px dashed #0066CC; | 方塊狀破折線 |
| 實線 | height:1px; border:none; border-top:1px solid #555555; | 標準實線 |
| 雙線 | height:3px; border:none; border-top:3px double red; | 兩條平行實線 |
| 3D 凸脊 | height:5px; border:none; border-top:5px ridge green; | 立體凸起效果 |
| 3D 溝槽 | height:10px; border:none; border-top:10px groove skyblue; | 立體凹陷效果(上淺下深) |
<hr style="height:2px;border:none;border-top:2px dotted #185598;" />
<hr style="height:1px;border:none;border-top:1px dashed #0066CC;" />
<hr style="height:1px;border:none;border-top:1px solid #555555;" />
<hr style="height:3px;border:none;border-top:3px double red;" />
<hr style="height:5px;border:none;border-top:5px ridge green;" />
<hr style="height:10px;border:none;border-top:10px groove skyblue;" />
height:3px; background:linear-gradient(90deg, red, yellow, blue); border:none;background-position + animation 實現跑馬燈分隔線<hr> 標籤,僅用 CSS 美化,維持無障礙語意<hr> 為空元素,寫法 <hr> 或 <hr /> 均可border-top 渲染可能有 1px 偏差,可用 border-bottom 替代測試@media print 中調整顏色對比