在 HTML 中新增水平線
HTML 中的<hr>標籤是一個水平線,用於定義 HTML 頁面中的主題斷開。它通常用於顯示水平線以分隔內容或更改 HTML 頁面中內容的顯示方式。它僅包含 HTML 中的開始標籤。
語法
下面顯示了在 HTML 中使用<hr>標籤的方法:
<hr>………
HTML <hr>標籤支援以下附加屬性:
屬性 |
值 |
描述 |
|---|---|---|
align |
left center right |
指定水平線的對齊方式。 |
noshade |
Noshade |
刪除大多數瀏覽器顯示的常用陰影效果。 |
size |
畫素或% |
指定水平線的高度。 |
width |
畫素或% |
指定水平線的寬度。 |
示例
以下示例演示了在 HTML 中使用<hr>標籤:
<!DOCTYPE html> <html> <head> <title>HTML hr Tag</title> </head> <body> <p>This text will be followed by a horizontal line</p> <hr> <p>Another horizontal line</p> <hr> </body> </html>
示例
現在,讓我們透過為<hr>標籤的屬性賦值來檢視一個示例:
<!DOCTYPE html> <html> <head> <title>HTML hr Tag</title> </head> <body> <p>This text will be followed by a horizontal line</p> <hr style="width:30%;text-align:left;margin-left:0"> <p>Continue another sentence here....</p> </body> </html>
示例
以下是 CSS 中無陰影<hr>元素的示例:
<!DOCTYPE html> <html> <body> <p>Demonstrating noshaded horizontal line:</p> <hr> <p>Applying styling sheet</p> <hr style="height:2px;border-width:0;color:grey;background-color:red"> </body> </html>
示例
以下是使用 CSS 演示<hr>的高度元素的示例:
<!DOCTYPE html> <html> <body> <p>Height of horizontal line:</p> <hr> <p>A horizontal line with a height of 50 pixels:</p> <hr style="height:50px"> </body> </html>
示例
在以下示例中,我們使用 CSS 屬性更改<hr>元素的寬度:
<!DOCTYPE html> <html> <body> <p>Normal horizontal line:</p> <hr> <p>A horizontal line with a width of 30 %:</p> <hr style="width:30%"> </body> </html>
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP