如何在 HTML5 中包含文档或节的头部?


Header 标签用于表示一个容器,其中包含一组导航链接或介绍性内容。它包含一个或多个标题元素、图标和作者信息。

在 HTML 中,我们可以放置多个 <header> 元素,但 <header> 元素不能放置在 <footer>、另一个 <header> 或 <address> 内。<header> 标签包含开始标签、结束标签,并在两者之间放置内容。

语法

以下是 <header> 标签在 HTML 中的用法 -

<header> …………</header>

示例

以下是 <header> 标签在 HTML 中的示例 -

Open Compiler
<!DOCTYPE html> <html> <body> <h1>Header Tag</h1> <hr> <article> <header> <h3>TutorialsPoint Demonstrate the Header Tag</h3> <p>Article written by BhanuPriya</p> <p> Header tag is used to represent a container consists of set of navigational links or introductory content . It consists of one or more heading elements, icons and authorship information. </p> </header> </article> </body> </html>

我们可以将 CSS 应用于 <header> 元素并使用默认值,以下是大多数浏览器用来显示 <header> 元素的语法。

header { display: block; }

示例

在下面的示例中,我们使用 HTML 中的 <header> 标签来表示导航链接。

Open Compiler
<!DOCTYPE html> <html> <body> <h1>HTML Header Tags represent Links</h1> <header> <a href="https://tutorialspoint.com/questions/category/c"> C Programming</a> || <a href="https://tutorialspoint.com/questions/category/operating-system"> Operating System</a> || <a href="https://tutorialspoint.com/questions/category/rdbms"> RDBMS</a> || <a href="https://tutorialspoint.com/questions/category/computer-network"> Networking</a> </header> </body> </html>

在 HTML 文档中包含一个节

Section 是 HTML 中使用的一个标签,它定义了文档的节,例如标题、页脚、章节等。

  • Section 标签将文档内容分成两部分:节和子节。

  • 当需要两个标题或页脚或章节或文档的其他部分时,它非常有用。

  • Section 标签将相关内容分组到一个通用块中。

  • 它是一个语义元素,可以向浏览器和开发人员描述含义。

  • Section 具有开始和结束标签,<section> </section>

语法

以下是 section 标签在 HTML 中的用法 -

<section> Content </section>

示例

让我们看看 section 标签的一个示例 -

Open Compiler
<!DOCTYPE html> <html> <body> <h1>Tutorials Point</h1> <!-- html section tag is used here --> <section> <h2>----- Section 1-----</h2> <p>HTML Tutorial</p> </section> <section> <h2>----- Section 2-----</h2> <p>JAVA Tutorial</p> </section> <section> <h2>-----Section 3-----</h2> <p>Oracle Tutorial</p> </section> </body> </html>

更新于: 2023年10月10日

446 次浏览

开启您的 职业生涯

通过完成课程获得认证

开始学习
广告