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 & 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 & 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 & 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 & 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 & 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>© 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