0
点赞
收藏
分享

微信扫一扫

HTML 5中又新增加main标签

那小那小 2022-12-05 阅读 57


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



  


举报

相关推荐

0 条评论