HTML 5中又新增加main标签

HTML 5新增加的标签元素已经够多的了,在2013年2月份,又增加了<main>标签,参考:
http://www.w3.org/html/wg/drafts/html/master/grouping-content.html#the-main-element

  其中定义如下:
The main element represents the main content of the body of a document or application. The main content area consists of content that is directly related to or expands upon the central topic of a document or central functionality of an application.

Authors must not include more than one main element in a document.

Authors must not include the main element as a child of an article, aside, footer, header or nav element

   也就是说,它是表达了document中的body的主要内容,但不能在一个document中有多个main,不能在article,aside,footer,header或者nav中包含main.下面是个例子:
 

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Using main</title>
</head>
<body>
	<header>My page</header>
	<nav>
		[url=#]Home[/url]
	</nav>
	<main>
		<article>
			<h1>My article</h1>
			Content

		</article>
		<aside>
			More information

		</aside>
	</main>
	<footer>Copyright 2013</footer>
</body>
</html>



    标准中的又一个例子:


<main>

  <h1>Skateboards</h1>
  The skateboard is the way cool kids get around

  
  <article>
  <h2>Longboards</h2>
  Longboards are a type of skateboard with a longer 
  wheelbase and larger, softer wheels.

  ... 

  ... 

  </article>

  <article>
  <h2>Electric Skateboards</h2>
  These no longer require the propelling of the skateboard
  by means of the feet; rather an electric motor propels the board, 
  fed by an electric battery.

  ... 

  ... 

  </article>

</main>

  <!-- other content -->

  
  • 4
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
H5语义化标签HTML5标准引入的一种标记方式,主要用于表达网页内容的结构与含义,可以提高网页的可读性和可维护性,以及增强搜索引擎的理解能力。 在实际开发,使用H5语义化标签的频率较高。随着HTML5标准的普及和浏览器对标签的兼容性提升,开发人员更加倾向于使用语义化标签。它们可以将页面分为多个有意义的块,如<header>,<nav>,<main>,<article>,<footer>等,使得页面结构更加清晰易懂。 使用H5语义化标签的好处之一是改善网页的可访问性。对于一些辅助技术,如屏幕阅读器,语义化标签可以提供更好的理解和导航体验。这对于视力受限的用户或身体功能障碍者来说尤为重要。 另一个原因是搜索引擎优化(SEO)。搜索引擎通过分析网页的结构和内容来确定其排名。语义化标签可以更准确地描述页面的结构和内容,提供更多的关键信息,从而增加搜索引擎索引的准确度和可靠性。 虽然H5语义化标签有诸多优点,但在实际开发,仍然有些开发人员为了追求页面效果或兼容性,而未充分使用语义化标签。这样可能会导致页面结构混乱、可读性差,增加后期维护的难度。 总的来说,随着对H5语义化标签的认识不断加深和浏览器的支持,开发人员普遍倾向于更多地使用这些语义化标签以提升网页的质量和性能。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值