HTML教程
HTML5教程
HTML参考手册

如何在HTML中添加行?

如何在HTML中添加行

在HTML中,我们可以使用以下不同方式轻松地在文档中添加水平线:
使用HTML标签 使用内部CSS

使用HTML

如果我们想使用 HTML标签,那么我们必须按照以下步骤进行操作。使用这些步骤,我们可以轻松地添加以下行:
第1步:首先,我们必须在任何文本编辑器中键入Html代码或打开现有的文本编辑器中的 HTML 文件,我们要在其中添加水平线。
<!Doctype Html>
<Html>
<Head>
<Title>
Add the Line using Html tags
</Title>
</Head>
<Body>
This page helps you to understand how to add the line in Html document.
And, this section helps you to understand how to add the line using the Html tags.
</Body>
</Html>
第2步:现在,将光标放在我们要在HTML文档中添加行的点。并且,此时我们必须使用Html的 标签
<hr>
第3步:现在,我们必须添加标记的属性,该属性定义线的大小,颜色和宽度。因此,我们必须在标记内键入size,width和color属性。
<hr size="" width="" color="">
步骤4:然后,我们必须指定这些属性的值。
<hr size="value of size in numbers" width="value of width attribute in percentage" color="value of color">
步骤5:而且,最后,我们必须保存HTML代码,然后在浏览器中运行文件。
<!Doctype Html>
<Html>
<Head>
<Title>
Add the Line using Html tags
</Title>
</Head>
<Body>
This page helps you to understand how to add the line in Html document.
<hr size="8" width="90%" color="red">
And, this section helps you to understand how to add the line using the Html tag.
</Body>
</Html>
上述HTML代码的输出显示在以下屏幕截图中:
如何在HTML中添加行

使用内部CSS

如果我们想使用内部样式表,那么我们必须遵循以下步骤。使用这些步骤,我们可以轻松地添加以下行:
步骤1:首先,我们必须在任何文本编辑器中键入Html代码,或在文本中打开现有的Html文件。我们要在其中添加水平线的编辑器。
<!Doctype Html>
<Html>
<Head>
<Title>
Add the Line using Internal CSS.
</Title>
</Head>
<Body>
This page helps you to understand how to add the line in Html document.
And, this section helps you to understand how to add the line using the Internal Cascading Style Sheet.
</Body>
</Html>
第2步:现在,我们必须将标题标签紧靠在Html文档的 head标签之后,然后在其中定义样式 <style> 标记,如以下块所示。然后,我们必须键入hr CSS标签以设置水平线的样式。
<Head>
<Title>
Add the Line using Internal CSS.
</Title>
<style>
hr
{
}
</style>
</Head>
步骤3:现在,我们必须定义hr CSS标签的属性。因此,我们将在以下代码段中定义不同的 属性:
<Head>
<Title>
Add the Line using Internal CSS.
</Title>
<style>
hr
{
width: 80%;
height: 2px;
background-color: pink;
margin-bottom: 7px;
margin-right: auto;
margin-left: auto;
margin-top: 9px;
border-width: 4px;
border-color: blue;
}
</style>
</Head>
步骤4:现在,我们必须输入HTML文件正文中的 标签,以在网页上显示水平线。最后,我们必须保存Html文件,然后在Internet浏览器中运行该文件。
<!Doctype Html>
<Html>
<Head>
<Title>
Add the Line using Internal CSS.
</Title>
<style>
hr
{
width: 80%;
height: 2px;
background-color: pink;
margin-bottom: 7px;
margin-right: auto;
margin-left: auto;
margin-top: 9px;
border-width: 4px;
border-color: blue;
}
</style>
</Head>
<Body>
This page helps you to understand how to add the line in Html document.
<hr>
And, this section helps you to understand how to add the line using the Internal Cascading Style Sheet.
</Body>
</Html>
上述HTML代码的输出显示在以下屏幕截图中:
如何在HTML中添加行
昵称: 邮箱:
Copyright © 2022 立地货 All Rights Reserved.
备案号:京ICP备14037608号-4