简体   繁体   English

HTML5 主要用途

[英]HTML5 Main Usage

Previously I'd lay out a main container on an HTML page to wrap most of my body content in. for example, an 'about' page:以前,我会在 HTML 页面上布置一个主容器来包装我的大部分正文内容。例如,“关于”页面:

<header>
    <!--header markup -->
</header>

<div id="container">
    <!--articles, images, etc for the about section -->
</div>

<footer>
    <!--footer markup -->
</footer>    

would HTML5's <main> tag be ideal to take the place of my 'div id="container"' in this case?在这种情况下,HTML5 的<main>标签是否适合代替我的 'div id="container"'?

In a word yes.总之一句话是的。

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.主要内容区域由与文档的中心主题或应用程序的中心功能直接相关或扩展的内容组成。

w3c specs w3c 规格

See here for more info在这里查看更多信息

You should use it for content that is unique to the page.您应该将它用于页面独有的内容。 So yes, headers and footers are naturally left out.所以是的,页眉和页脚自然被排除在外。 From there on, it depends what else you have there.从那以后,这取决于你在那里还有什么。 If there's a sidebar, for example, with template-loaded content that is common across many pages, you should consider leaving that out as well.例如,如果有一个侧边栏,其中包含在许多页面中通用的模板加载内容,您也应该考虑将其省略。

Just replace the tag of most important part of your website with <main> .只需将您网站最重要部分的标签替换为<main> Mostly <main> will replace <section> (In your case, <div> , and originally it should be <section> ).大多数情况下<main>将替换<section> (在你的情况下, <div> ,最初它应该是<section> )。 Notice that I put emphasis on the word part because <main> is not for sectioning your document, its purpose is just: point out what's the most important part of your website/application.请注意,我强调了单词部分,因为<main>不是用于分割您的文档,它的目的只是:指出您的网站/应用程序中最重要的部分。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM