<hr> 代表段落層級的主題分隔(Horizontal Rule),語意上區隔內容區塊,而非單純畫線。本文說明標籤用法、HTML/XHTML 差異與樣式建議。
border-bottom 或 <div class="divider">)| 規範 | 寫法 |
|---|---|
| HTML / HTML5 | <hr>(空元素,無結束標籤) |
| XHTML | <hr />(自閉合,斜線前建議加空格) |
align, noshade, size, width, color 均**不建議使用**hr {
border: none;
height: 2px;
background: linear-gradient(90deg, transparent, #1976d2, transparent);
margin: 2rem 0;
}
/* 或使用 border-top 打造虛線 */
hr.dashed { border: none; border-top: 1px dashed #dee2e6; height: 0; }
<hr> 作為內容分段依據<hr>,改用適當的標題層級(<h2>、<h3>)結構化內容