文
章
目
录
章
目
录
HTML标题或HTML标题标签可以定义为您希望在网页上显示的标题或副标题。当您将文本放在标题标签<h1>……</h1>内时,它以粗体格式显示在浏览器上,文本的大小取决于标题级别。
有六种不同的HTML标题,分别由<h1>到<h6>标签定义,从最高级别的h1(主标题)到最低级别的h6(最不重要的标题)。
h1是最大的标题标签,h6是最小的标题标签。因此,h1用于最重要的标题,h6用于最不重要的标题。
HTML中的标题有助于搜索引擎理解和索引网页的结构。
注意:整个网页内容的主要关键词应该由h1标题标签显示。
示例:
<h1>Heading no. 1</h1>
<h2>Heading no. 2</h2>
<h3>Heading no. 3</h3>
<h4>Heading no. 4</h4>
<h5>Heading no. 5</h5>
<h6>Heading no. 6</h6>
标题元素(h1….h6)应该仅用于标题。不应该仅仅用于使文本变粗或变大。
HTML标题也可以与嵌套元素一起使用。以下是不同代码,展示了如何使用标题元素的方式。
示例:
<!DOCTYPE html>
<html>
<head>
<title>Heading elements</title>
</head>
<body>
<h1>This is main heading of page. </h1>
<p>h1 is the most important heading, which is used to display the keyword of page </p>
<h2>This is first sub-heading</h2>
<p>h2 describes the first sub heading of page. </p>
<h3>This is Second sub-heading</h3>
<p>h3 describes the second sub heading of page.</p>
<p>We can use h1 to h6 tag to use the different sub-heading with their paragraphs if
required.
</p>
</body>
</html>
支持的浏览器
OperaSafari
元素 | Chrome | IE | Firefox | Opera | Safari |
<h1> 到<h6> | 支持 | 支持 | 支持 | 支持 | 支持 |