如何在 HTML5 中包含文档或部分的头部?
Header 标签用于表示一个包含一组导航链接或介绍性内容的容器。它包含一个或多个标题元素、图标和作者信息。
在 HTML 中,我们可以放置多个 <header> 元素,但 <header> 元素不能放置在 <footer>、另一个 <header> 或 <address> 元素内部。<header> 标签由开始标签、结束标签组成,其间放置内容。
语法
以下是 <header> 标签在 HTML 中的用法 -
<header> …………</header>
示例
以下是 <header> 标签在 HTML 中的示例 -
<!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> 标签来表示导航链接。
<!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 标签的示例 -
<!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>
广告