> For the complete documentation index, see [llms.txt](https://lochiwei.gitbook.io/web/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lochiwei.gitbook.io/web/html/element/hr.md).

# \<hr>

🔰 [HTML](/web/html.md) ⟩ [Elements](/web/html/element.md) ⟩ \<hr>

{% hint style="success" %}
(Horizontal Rule)

represents a thematic break between paragraph-level elements.
{% endhint %}

{% tabs %}
{% tab title="⭐️ 重點" %}
{% hint style="danger" %}
注意：\
<**hr**> 預設只有 **1px** 的 **border**，**沒有 content height**❗️
{% endhint %}

```css
/* default styles */
hr {
    display: block;
    unicode-bidi: isolate;
    margin-block-start: 0.5em;
    margin-block-end: 0.5em;
    margin-inline-start: auto;
    margin-inline-end: auto;
    overflow: hidden;
    
    /* ⭐️ 預設只有 border, 注意：content height = 0❗️ */
    border-style: inset;
    border-width: 1px;
}
```

{% endtab %}

{% tab title="💈範例" %}

* replit ⟩ [style \<hr>](https://replit.com/@pegasusroe/style-lesshrgreater#style.css)

```css
:root {
    --x: 2px;       /* shadow offset */
}

html {
    background-color: tomato;
}

body {
    background-color: #ccc;
    color: #333;
    padding: 1em;
}

hr.gradient {
    border: 0;
    height: 2px;
    background-image: 
        linear-gradient(to right, goldenrod, red, yellow);
    border-radius: 2px;
}

hr.transparent {
    border: 0;
    height: 1px;
    
    background-image: linear-gradient(to right, 
        rgba(0, 0, 0, 0),
        rgba(0, 0, 0, 0.75), 
        rgba(0, 0, 0, 0)
    );
}

hr.dashed {
    border: 0;
    border-bottom: 1px dashed #ccc;
    background: #999;
}

hr.solid {

    /* ⭐️ 如果要使用 content-box 的背景色 */
    background-color: #999;
    height: 8px;                /* ⭐️ 要設定高度❗️ */

    border-style: none;         /* ⭐️ 關閉 border */
    border-radius: 4px;
}

hr.dotted {

    /* ⭐️ 只開放 border-top */
    border-style: dotted none none;

    border-width: 8px;
    border-color: #999;
    width: 100px;
}


hr.thin {
    border: 0;
    height: 0;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    border-bottom: 1px solid rgba(255, 255, 255, 0.3);
}

hr.height {
    height: 12px;
}

hr.left {
    margin-right: 50%;
}

hr.right {
    margin-left: 50%;
}

hr.border0 {
    border: 0;
}

hr.bg {
    background-color: #eee;
}

hr.shadow {
    box-shadow: var(--x) var(--x) var(--x) 0px #888888 inset;
}
```

{% endtab %}

{% tab title="🗺️ 圖表" %}
{% embed url="<https://codepen.io/lochiwei/pen/vYmoWOw>" %}

{% embed url="<https://replit.com/@pegasusroe/style-lesshrgreater#index.html>" %}
{% endtab %}

{% tab title="📘 手冊" %}

* [HTML](https://developer.mozilla.org/en-US/docs/Web/HTML) ⟩ [Elements](https://developer.mozilla.org/en-US/docs/Web/HTML/Element) ⟩ [\<hr>](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/hr)
* [HTMLElement](/web/browser/dom/type/htmlelement.md) ⟩ [HTMLHRElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLHRElement)
  {% endtab %}
  {% endtabs %}
