Html 页脚可以有页眉标记吗?

Html 页脚可以有页眉标记吗?,html,dom,header,footer,Html,Dom,Header,Footer,我已经讨论了页眉和页脚。由于HTML5提供了页眉、页脚和内容元素,我认为它应该在每页使用一次。我在下面的片段中陈述了它们 <!-- My understanding --> <header> <!-- code goes here --> </header> <content> <!-- code goes here --> <!-- code goes here --> </con

我已经讨论了页眉和页脚。由于HTML5提供了页眉、页脚和内容元素,我认为它应该在每页使用一次。我在下面的片段中陈述了它们

<!-- My understanding -->
<header>
    <!-- code goes here -->
</header>
<content>
    <!-- code goes here -->
    <!-- code goes here -->
</content>
<footer>
    <!-- code goes here -->
</footer>

很少有人有下面这样的页眉、页脚元素方法

<!-- People understanding -->
<header>
    <!-- code goes here -->
</header>
<content>
    <!-- code goes here -->
    <!-- code goes here -->
</content>
<footer>
    <header>
        <!-- They also use <header> in footer. -->
    </header>
    <!-- code goes here -->
</footer>


页眉
可以在
页脚
元素中使用吗?换句话说,您建议如何构建HTML结构?

我建议您应该坚持您的第一行想法:

// My understanding
<header>
    //code goes here
</header>
<content>
    //code goes here
    //code goes here
</content>
<footer>
    //code goes here
</footer>
//我的理解
//代码在这里
//代码在这里
//代码在这里
//代码在这里
对我来说,理解如何以这种格式创建HTML文件更容易。

第二个示例在技术上可以很好地工作,因为所有的
在功能上与
类似,但在语义上这是非常糟糕的做法。我同意你最初的想法,这肯定是这些元素的精神所在。

不,这是无效的

header
元素表示内容的页眉,但是
header
元素不能是
footer
元素的后代

footer
部分声明
footer
元素为:

流内容,但没有
页眉
页脚
、或
元素子体

如果将以下代码粘贴到中,将出现以下错误:

第8行,第20列:元素页眉不能显示为页脚元素的后代。


标题
忽略无效的
content
元素,您的第一个示例有效,您应该坚持此操作。

根据:

HTML元素表示一组介绍性的或 导航设备。它可能包含一些标题元素,但也包含其他元素 元素,如徽标、包装的部分标题、搜索表单等 开


因此,我不建议您在页眉标记中使用页脚标记。

元素不引入新的节,而是节的头,并且不要求每个站点只使用一个元素。@Basjobsen这是真的,然而,HTML5规范明确规定,
footer
元素不能有
标题
子元素。我的答覆引述有关章节。
<!doctype html>
<html>
    <head>
        <title>Title</title>
    </head>
    <body>
        <footer>
            <header>
            </header>
        </footer>
    </body>
</html>