我应该使用元素吗?

时间:2022-05-18 07:13:37

I've stumbled about the element on w3schools but as far as caniuse.com told me, the element isn't supported by IE, Opera Mini and the UC Browser for Android.

我偶然发现了w3schools上的元素,但就caniuse.com告诉我,IE,Opera Mini和Android浏览器不支持该元素。

Would I be better by going with a <main> element or should I stick with a <div id="main">?

使用

元素会更好吗,还是应该坚持使用

2 个解决方案

#1


0  

caniuse.com told me, the element isn't supported by IE, Opera Mini and the UC Browser for Android

caniuse.com告诉我,IE,Opera Mini和Android浏览器不支持该元素

That isn't what it says.

这不是它所说的。

It says "Partial support" and:

它说“部分支持”和:

Partial support refers to missing the default styling, as technically the elements are considered "unknown". This is easily taken care of by manually setting the default display value for each tag

部分支持是指缺少默认样式,因为从技术上讲,元素被认为是“未知”。通过手动设置每个标签的默认显示值,可以轻松完成此操作

So if main has the appropriate semantics, then use it. Just make sure to explicitly set display: block.

因此,如果main具有适当的语义,那么使用它。只需确保明确设置display:block。

If the browser doesn't expose the semantics of using main then it will have no semantics, which is the same as a div.

如果浏览器没有公开使用main的语义,那么它将没有语义,这与div相同。

#2


0  

From the looks of it I wouldn't worry about compatibility, unless you are trying to support IE 8 and below.. You can cover all your bases by using both <main role="main"> per MDN

从它的外观来看,我不担心兼容性,除非你试图支持IE 8及以下..你可以通过使用每个MDN的

覆盖所有基础

The element is widely supported. For Internet Explorer 11 and below, it is suggested that an ARIA role of "main" be added to the element to ensure it is accessible (screen readers like JAWS, used in combination with older versions of Internet Explorer, will be able to understand the semantic meaning of the element once this role attribute is included).

该元素得到广泛支持。对于Internet Explorer 11及更低版本,建议在元素中添加ARIA角色“main”以确保其可访问(像JAWS这样的屏幕阅读器,与旧版本的Internet Explorer结合使用,将能够理解包含此角色属性后元素的语义含义)。

#1


0  

caniuse.com told me, the element isn't supported by IE, Opera Mini and the UC Browser for Android

caniuse.com告诉我,IE,Opera Mini和Android浏览器不支持该元素

That isn't what it says.

这不是它所说的。

It says "Partial support" and:

它说“部分支持”和:

Partial support refers to missing the default styling, as technically the elements are considered "unknown". This is easily taken care of by manually setting the default display value for each tag

部分支持是指缺少默认样式,因为从技术上讲,元素被认为是“未知”。通过手动设置每个标签的默认显示值,可以轻松完成此操作

So if main has the appropriate semantics, then use it. Just make sure to explicitly set display: block.

因此,如果main具有适当的语义,那么使用它。只需确保明确设置display:block。

If the browser doesn't expose the semantics of using main then it will have no semantics, which is the same as a div.

如果浏览器没有公开使用main的语义,那么它将没有语义,这与div相同。

#2


0  

From the looks of it I wouldn't worry about compatibility, unless you are trying to support IE 8 and below.. You can cover all your bases by using both <main role="main"> per MDN

从它的外观来看,我不担心兼容性,除非你试图支持IE 8及以下..你可以通过使用每个MDN的

覆盖所有基础

The element is widely supported. For Internet Explorer 11 and below, it is suggested that an ARIA role of "main" be added to the element to ensure it is accessible (screen readers like JAWS, used in combination with older versions of Internet Explorer, will be able to understand the semantic meaning of the element once this role attribute is included).

该元素得到广泛支持。对于Internet Explorer 11及更低版本,建议在元素中添加ARIA角色“main”以确保其可访问(像JAWS这样的屏幕阅读器,与旧版本的Internet Explorer结合使用,将能够理解包含此角色属性后元素的语义含义)。