html5横线代码
在HTML5中,你可以使用<hr>元素来插入水平线。<hr>元素用于创建分隔线或其他视觉分隔效果。
html<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Horizontal Line Example</title>
</head>
<body>
<p>Some content above the horizontal line.</p>
<!-- Horizontal line -->
<hr>
<p>Some content below the horizontal line.</p>
</body>
</html>
在这个例子中,<hr>元素用于在页面中创建一个水平线。你可以在水平线上方和下方放置其他内容。
color: 定义水平线的颜色。size: 定义水平线的高度。width: 定义水平线的宽度。align: 定义水平线在其容器中的对齐方式。
html<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Customized Horizontal Line</title>
</head>
<body>
<p>Some content above the customized horizontal line.</p>
<!-- Customized Horizontal line -->
<hr color="blue" size="3" width="50%" align="center">
<p>Some content below the customized horizontal line.</p>
</body>
</html>
在这个例子中,水平线被定制为蓝色,高度为3个像素,宽度占据父容器的50%,并且居中对齐。你可以根据需要调整这些属性以满足你的设计要求。