HTML hr 标签

htmlweb developmentfront end technology更新于 2025/6/27 23:40:17

HTML 中的 <hr> 标签会在 HTML 文档中添加一条分隔线,用于分隔内容。在 HTML5 中,主题分隔符由 <hr> 标签定义。它没有结束标签。

现在让我们看一个实现 <hr> 标签的示例 −

示例

<!DOCTYPE html>
<html>
<head>
<title>Document Title</title>
</head>
<body>
   <h1>Products</h1>
   <p>Here are the products −</p>
   <h2>Clothing</h2>
   <p>Clothing includes T-Shirts, Shirts, Jeans, Trousers and Hoodie.</p>
   <hr>
   <h2>Electronics</h2>
   <p>Electronics includes Mobile, Mobile Accessories,Laptops, Desktop systems, etc.</p>
</body>
</html>

输出

在上面的例子中,我们首先设置了一个部分 −

<h2>Clothing</h2><p></p>
<p>Clothing includes T-Shirts, Shirts, Jeans, Trousers and Hoodie.</p>

之后,我们使用 <hr> 标签将上面的内容与下面的内容分开 −

<hr>
<h2>Electronics</h2>
<p>Electronics includes Mobile, Mobile Accessories,Laptops, Desktop systems, etc.</p>

相关文章


有用资源