首页 > 其他分享 >web前端:main、header、footer、nav、article、section标签的用法

web前端:main、header、footer、nav、article、section标签的用法

时间:2023-08-07 21:59:22浏览次数:46  
标签:web Training footer 标签 header article main 页面

HTML5
添加了诸如main、header、footer、nav、article、section等大量新标签,这些新标签为开发人员提供更多的选择和辅助特性。

默认情况下,浏览器呈现这些新标签的方式与div相似。然而,合理地使用它们,可以使你的标签更加的语义化。辅助技术(如:屏幕阅读器)可以通过这些标签为用户提供更加准确的、易于理解的页面信息。

1.<main>标签

main标签用于呈现网页的主体内容,且每个页面只能有一个。这意味着它应包含与页面中心主题相关的信息,而不应包含如导航连接、网页横幅等可以在多个页面中重复出现的内容。

main标签的语义化特性可以使辅助技术快速定位到页面的主体。有些页面中有“跳转到主要内容”的链接,使用main标签可以使辅助设备自动获得这个功能。

<header>
  <h1>Weapons of the Ninja</h1>
</header>

<main>
 //网页的主体内容 
</main>

<footer></footer> 

//main标签应该在header标签与footer标签之间。

2.<article>标签

article是另一个具有语义化特性的HTML5新标签。article是一个分段标签,用于呈现独立及完整的内容。这个标签适用于博客入口、论坛帖子或者新闻文章。

<h1>Deep Thoughts with Master Camper Cat</h1>
<main>
  <article>
    <h2>The Garfield Files: Lasagna as Training Fuel?</h2>
    <p>The internet is littered with varying opinions on nutritional paradigms, from catnip paleo to hairball cleanses. But let's turn our attention to an often overlooked fitness fuel, and examine the protein-carb-NOM trifecta that is lasagna...</p>
  </article>
//用于呈现独立及完整的内容
  <img src="samuraiSwords.jpeg" alt="">

  <article>
    <h2>Defeating your Foe: the Red Dot is Ours!</h2>
    <p>Felines the world over have been waging war on the most persistent of foes. This red nemesis combines both cunning stealth and lightening speed. But chin up, fellow fighters, our time for victory may soon be near...</p>
  </article>

  <img src="samuraiSwords.jpeg" alt="">

  <article>
    <h2>Is Chuck Norris a Cat Person?</h2>
    <p>Chuck Norris is widely regarded as the premier martial artist on the planet, and it's a complete coincidence anyone who disagrees with this fact mysteriously disappears soon after. But the real question is, is he a cat person?...</p>
  </article>
</main>

3.<sections>标签

section也是一个HTML5新标签,与article标签的语义含义略有不同。article用于独立的、完整的内容,而section用于对与主题相关的内容进行分组。它们可以根据需要嵌套着使用。举个例子:如果一本书是一个article的话,那么每一个章节就是sectio。当内容组之间没有联系时,可以使用div。

    • div:内容组
    • section:有联系的内容组
    • article:独立完整的内容

4.<header>标签

header也是一个具有语义化的、提升页面可访问性的HTML5标签。它可以为父级标签呈现简介信息或者导航链接,适用于那些在多个页面顶部重复出现的内容。

与main类似,header的语义化特性也可以使辅助技术快速定位到它的内容。

注意:

header用在HTML文档的body标签中。这点与包含页面标题、元信息的head标签不同。

<body>
  <header>
    <h1>Training with Camper Cat</h1>
  </header>
//适用于那些在多个页面顶部重复出现的内容,导航或简介信息
  <main>
    <section id="stealth">
      <h2>Stealth &amp; Agility Training</h2>
      <article><h3>Climb foliage quickly using a minimum spanning tree approach</h3></article>
      <article><h3>No training is NP-complete without parkour</h3></article>
    </section>
    <section id="combat">
      <h2>Combat Training</h2>
      <article><h3>Dispatch multiple enemies with multithreaded tactics</h3></article>
      <article><h3>Goodbye world: 5 proven ways to knock out an opponent</h3></article>
    </section>
    <section id="weapons">
      <h2>Weapons Training</h2>
      <article><h3>Swords: the best tool to literally divide and conquer</h3></article>
      <article><h3>Breadth-first or depth-first in multi-weapon training?</h3></article>
    </section>
  </main>
</body>

5.<nav>标签

nav也是一个具有语义化特性的HTML5标签,用于呈现页面中的主导航链接。它可以使屏幕阅读器快速识别页面中的导航信息。

对于页面底部辅助性质的站点链接,不需要使用nav,用footer会更好。

<body>
  <header>
    <h1>Training with Camper Cat</h1>

    <nav>
      <ul>
        <li><a href="#stealth">Stealth &amp; Agility</a></li>
        <li><a href="#combat">Combat</a></li>
        <li><a href="#weapons">Weapons</a></li>
      </ul>
    </nav>
//用于呈现页面中的主导航链接

  </header>
  <main>
    <section id="stealth">
      <h2>Stealth &amp; Agility Training</h2>
      <article><h3>Climb foliage quickly using a minimum spanning tree approach</h3></article>
      <article><h3>No training is NP-complete without parkour</h3></article>
    </section>
    <section id="combat">
      <h2>Combat Training</h2>
      <article><h3>Dispatch multiple enemies with multithreaded tactics</h3></article>
      <article><h3>Goodbye world: 5 proven ways to knock out an opponent</h3></article>
    </section>
    <section id="weapons">
      <h2>Weapons Training</h2>
      <article><h3>Swords: the best tool to literally divide and conquer</h3></article>
      <article><h3>Breadth-first or depth-first in multi-weapon training?</h3></article>
    </section>
  </main>
</body>

6.<footer>标签

与header和nav类似,footer也具有语义化特性,可以使辅助设备快速定位到它。它位于页面底部,用于呈现版权信息或者相关文档链接

<body>
  <header>
    <h1>Training</h1>
    <nav>
      <ul>
        <li><a href="#stealth">Stealth &amp; Agility</a></li>
        <li><a href="#combat">Combat</a></li>
        <li><a href="#weapons">Weapons</a></li>
      </ul>
    </nav>
  </header>
  <main>
    <section id="stealth">
      <h2>Stealth &amp; Agility Training</h2>
      <article><h3>Climb foliage quickly using a minimum spanning tree approach</h3></article>
      <article><h3>No training is NP-complete without parkour</h3></article>
    </section>
    <section id="combat">
      <h2>Combat Training</h2>
      <article><h3>Dispatch multiple enemies with multithreaded tactics</h3></article>
      <article><h3>Goodbye world: 5 proven ways to knock out an opponent</h3></article>
    </section>
    <section id="weapons">
      <h2>Weapons Training</h2>
      <article><h3>Swords: the best tool to literally divide and conquer</h3></article>
      <article><h3>Breadth-first or depth-first in multi-weapon training?</h3></article>
    </section>
  </main>
  <footer>&copy; 2016 Camper Cat</footer>//用于呈现版权信息或者相关文档链接
</body>

 

 

参考---https://blog.csdn.net/weixin_43386439/article/details/90208824

 

标签:web,Training,footer,标签,header,article,main,页面
From: https://www.cnblogs.com/pwindy/p/17612548.html

相关文章

  • CTFer成长记录——CTF之Web专题·攻防世界-php_rce
    一、题目链接https://adworld.xctf.org.cn/challenges/list?rwNmOdr=1691398818171二、解法步骤  RCE意思是(RemoteCodeExecution),远程代码执行漏洞。这里题目涉及到thinkphp5的框架,那么就可能有对应的漏洞。  ThinkPHP5漏洞Payload:  Thinkphp5.0.221、http://192.1......
  • CTFer成长记录——CTF之Web专题·攻防世界-Web_php_unserialize
    一、题目链接https://adworld.xctf.org.cn/challenges/list二、解法步骤  本题考察的是反序列化,反序列化的题都需要审计php代码,步骤也比较固定。<?phpif(isset($_GET['var'])){$var=base64_decode($_GET['var']);if(preg_match('/[oc]:\d+:/i',$var))......
  • webstorm无法启动、重装后无法启动(mac)
    #删除配置信息目录rm-rf~/Library/Preferences/WebStorm*#删除插件信息目录rm-rf~/Library/Application\Support/WebStorm*#缓存信息目录rm-rf~/Library/Caches/WebStorm*#删除日志信息目录rm-rf~/Library/Logs/WebStorm*#删除Webstorm.vmoptions......
  • Java Web Service Get请求使用指南
    JavaWebServiceGet请求使用指南在当今互联网时代,WebService已经成为了现代软件开发中不可或缺的一部分。而Java作为一种广泛使用的编程语言,自然也提供了丰富的工具和库来支持WebService的开发。本文将为大家介绍如何使用Java编程语言进行WebService的Get请求。JavaWebserv......
  • 软件测试|web自动化测试神器playwright教程(二十七)
    前言使用selenium进行web自动化测试,如果我们打开了多个网页,进行网页切换时,我们需要先获取各个页面的句柄,通过句柄来区分各个页面,然后使用switch_to.window()实现切换,这样的操作比较麻烦,playwright的网页切换比selenium更为简单快捷。本文就给大家介绍一下playwright多个网页的切......
  • 软件测试|web自动化测试神器playwright教程(二十八)
    前言在我们使用部分网站的时候,我们会遇到进行日期选择的问题,比如我们预定火车票或者预定酒店,需要选择发车日期或者酒店的入住与退房时间。我们执行自动化测试遇到日期控件时,如果可以输入,可以使用selenium的send_keys()方法进行输入,playwright同样也可以实现对日期控件的操作,本文......
  • 10 web服务
    web服务有三个角色:服务请求者、服务提供者、服务注册中心(登记服务并对其接口进行描述)。服务注册中心通过UDDI协议进行对服务的查询和发布。服务注册中心相当于生活中的搜索引擎。发现服务使用UDDI协议描述服务用WSDL协议:WSDL就是webService接口对应的WSDL文件,该文件通过xml格......
  • 牧云·云原生安全平台使用手册:镜像/容器/Web资产清点
    牧云·云原生安全平台 是长亭牧云团队以开源社区为生态载体技术积累为驱动所打造的云原生安全平台。本文将介绍如何使用牧云·云原生安全平台进行镜像/容器/Web资产清点。首先,在我们进行下面 镜像/容器/Web资产清点前,我们需要先安装探针进行资产的采集工作。探针的安装包括本地......
  • 国标GB28181视频平台LntonGBS(源码版)国标视频平台隐藏平台web页面不被访问的操作步骤
    LntonGBS国标视频云服务通过支持国标GB28181协议,实现了设备接入、实时监控直播、录像、语音对讲、云存储、告警、级联等功能。同时,它还支持将接入的视频流以多种格式(包括RTSP、RTMP、FLV、HLS、WebRTC)进行全终端、全平台分发,实现了无插件播放在Web浏览器、手机浏览器、微信端、PC客......
  • 阿里云: web如何直传oss & 常见问题
    阿里云:web如何直传oss&常见问题 如何使用input.Type=‘file‘拿到文件对象1、在页面中添加<inputtype="file"style="display:none"ref="input"@input="upload">在需要上传文件的地方增加<button@click="$refs.input.click()">......