gpt4 book ai didi

html - 我什么时候可以安全地使用 HTML5 中的新
元素?

转载 作者:技术小花猫 更新时间:2023-10-29 11:45:19 26 4
gpt4 key购买 nike

12 月 16 日,<main> 的 HTML5 扩展规范元素是 submitted to the W3C under something called an editors draft .摘要如下:

This specification is an extension to the HTML5 specification [HTML5]. It defines an element to be used for the identification of the main content area of a document. All normative content in the HTML5 specification, unless specifically overridden by this specification, is intended to be the basis for this specification.

The main element formalises the common practice of identification of the main content section of a document using the id values such as 'content' and 'main'. It also defines an HTML element that embodies the semantics and function of the WAI-ARIA [ARIA] landmark role=main.

例子:

<!-- other content -->

<main>

<h1>Apples</h1>
<p>The apple is the pomaceous fruit of the apple tree.</p>

<article>
<h2>Red Delicious</h2>
<p>These bright red apples are the most common found in many
supermarkets.</p>
<p>... </p>
<p>... </p>
</article>

<article>
<h2>Granny Smith</h2>
<p>These juicy, green apples make a great filling for
apple pies.</p>
<p>... </p>
<p>... </p>
</article>

</main>

<!-- other content -->

它包含所有信息,我觉得我应该开始将它整合到网页中。据我所知,HTML5 规范只是渐进的,新功能被“固定”到规范中而没有升级。我想这意味着浏览器会在可能的时候开始实现它——问题是,这需要多长时间,我怎么知道所有浏览器都支持它?我现在应该像这样构建它并求助于 polyfill 吗?

最佳答案

支持<main>将很像对 HTML 5 中引入的任何其他新容器元素的支持。

  • 足够新的浏览器将支持它。
  • 较旧的浏览器会让您将其设置为 display: block。并给你它的视觉效果
  • 旧版本的 IE 在没有 JavaScript shim 的情况下根本不支持它(它的工作方式与所有其他新容器元素的工作方式完全相同)。

“何时”取决于您需要何种级别的浏览器支持以及您对 JS shim 的依赖程度。

关于html - 我什么时候可以安全地使用 HTML5 中的新 <main> 元素?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13949009/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com