<main> 元素可以嵌套在 div 中还是必须是 body 的直接后代?
can <main> element be nested inside a div or must be a direct descendant of body?
我正在阅读文档,但我仍然不明白 <main>
元素是否可以嵌套在其他元素中,例如
<div>
<div>
<main>...</main>
</div>
</div>
或者它必须是主体的直系后代,例如
<body>
<main>...</main>
</body>
我看到的所有示例都将 main 显示为 body 的直接后代...
所以我有点困惑:将 main 放在除 body 之外的其他元素中是否正确? (当然只用一次)
每 the spec
4.4.13. The main element
Categories:
- Flow content.
- Palpable content.
Contexts in which this element can be used:
Where flow content is expected, but with no <article>
, <aside>
, <footer>
, <header>
or <nav>
element ancestors.
由于 <body>
和 <div>
元素可能包含流内容,您可以安全地嵌套它们。
我正在阅读文档,但我仍然不明白 <main>
元素是否可以嵌套在其他元素中,例如
<div>
<div>
<main>...</main>
</div>
</div>
或者它必须是主体的直系后代,例如
<body>
<main>...</main>
</body>
我看到的所有示例都将 main 显示为 body 的直接后代...
所以我有点困惑:将 main 放在除 body 之外的其他元素中是否正确? (当然只用一次)
每 the spec
4.4.13. The main element
Categories:
- Flow content.
- Palpable content.
Contexts in which this element can be used:
Where flow content is expected, but with no
<article>
,<aside>
,<footer>
,<header>
or<nav>
element ancestors.
由于 <body>
和 <div>
元素可能包含流内容,您可以安全地嵌套它们。