如何正确使用html5< main>元素 [英] How to correctly use the html5 <main> element

查看:66
本文介绍了如何正确使用html5< main>元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经对我的问题的答案进行了一些搜索,但是我似乎无法得到一个直接的答案,除了不能回答我的问题的粘贴后的答案.

I've done a few searches for my answer to my question, but I can't seem to get a straight answer other than the cut-and-pasted responses which DO NOT answer my question.

我的问题是,我可以在网站的不同页面中使用< main> 标记吗?"

My question is, "Can I use the <main> tag in different pages of my website?"

我研究过的网站状态:

The websites I've researched state:

" < main> 标记指定文档的主要内容.
< main> 元素内的内容对于文档应该是唯一的.
它不应包含在文档之间重复的任何内容>,例如侧边栏,导航链接,版权信息,站点徽标和搜索表单.
注意:文档.该元素不得为< article> < aside> &footer> <header> < nav> 元素."

"The <main> tag specifies the main content of a document.
The content inside the <main> element should be unique to the document.
It should not contain any content that is repeated across documents such as sidebars, navigation links, copyright information, site logos, and search forms.
Note: There must not be more than one <main> element in a document. The element must NOT be a descendant of an <article>, <aside>, <footer>, <header>, or <nav> element."

所以...
我了解< main> 标记指定了文档的主要内容.
我了解< main >元素内的内容对于文档应该是唯一的.
我也了解它不应包含跨文档重复的任何内容,例如侧栏,导航链接,版权信息,网站徽标和搜索表单.

So...
I understand the <main> tag specifies the main content of a document.
I understand that the content inside the <main> element should be unique to the document.
I also understand it should not contain any content that is repeated across documents such as sidebars, navigation links, copyright information, site logos, and search forms.

这是我的问题出现的地方……文档"是什么意思?

And here is where my question arises...what does it mean by "document?"

文档"一词的意思是:

A)我可以在index.html,about_us.html和contact.html中使用它,但在每个页面中只能使用一次.

或者是

B)我不能在网站的其他页面中使用< main> .那意味着如果我在index.html上使用它,那么我将无法在其他页面(如about.html或contact.html ...)上使用它??

B) I cannot use <main> within other pages of the website. Which would mean that if I use it on my index.html then I would not be able to use it in my other pages like about.html or contact.html...?

研究过的网站:
https://www.w3schools.com/tags/tag_main.asp
http://blog.teamtreehouse.com/use-html5-sectioning-elements

谢谢您的澄清.

推荐答案

是的,您可以在网站的不同页面中使用< main> 标记.

Yes you can use <main> tag in different pages of a website.

答案A.

文档是HTML文档的缩写,表示有效的html文件.不是html片段.

A document is short for HTML document, it means a valid html file. Not a html fragment.

< main> 有3个很好的用途.它可以帮助扫描网页的算法更有效.快速识别主要内容,因此不处理主要内容.可以使用CSS规则设置样式.它可以帮助用户使用屏幕阅读器.

There are 3 good uses for the <main>. It can help algorithms that scan web pages be more efficient. Quickly identify the main content, and as a consequence not process what is outside the main. It can be styled with a CSS rule. It can help users with screen readers.

更新:在进行中的html规范中,只要只有1个可见,就有可能具有多个< main> .

Update: Inside work in progress, html specification, it is possible to have multiple <main>, as long as only 1 is visible.

https://w3c.github.io/html/grouping-content.html#elementdef-main

这篇关于如何正确使用html5&lt; main&gt;元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆