2014-03-12 31 views
2

难道不是<header>HTML 5没有主页<header>?

我有这个基本结构,但我正在考虑封装一个标头,围绕正文开始和内容之间的所有内容,因为标题也附有这个不错的shema.org标记。好主意?

仅仅是因为有时标题不存在,但navbars实际上包含品牌名称,并且它们是标题themseves。

如果我这样做,我该如何标记什么<header>现在?标题内的部分不正确?只是一个正常的<div>我猜。

<body> 

<div class="nav1"><h1>brandname</h1><nav>...</nav></div> 

<header><h1>brandname</h1><p>slogan</p></header> <!-- sometimes this is not there --> 

<div class="nav2"><h1>brandname</h1><nav>...</nav></div> 

<div>content ... 

对此

<body> 
<header itemtype="http://schema.org/WPHeader" ...> 
<div class="nav1"><h1>brandname</h1><nav>...</nav></div> 

<div><h1>brandname</h1><p>slogan</p></div> <!-- sometimes this is not there --> 

<div class="nav2"><h1>brandname</h1><nav>...</nav></div> 
</header> 
<div>content ... 

多个头无效一方或?我正在考虑这样做,因为使用<header>而没有任何CSS样式仅用于语义标记。我可以考虑用这个方法创造的造型障碍,因此不能100%满意。

或者这是有效的。

<body> 

<header class="nav1"><h1>brandname</h1><nav>...</nav></header> 

<header><h1>brandname</h1><p>slogan</p></header> <!-- sometimes this is not there --> 

<header class="nav2"><h1>brandname</h1><nav>...</nav></header> 

<div>content ... 

//只是读html5: using header or footer tag twice?这一点,看起来像我坚持与第2解决方案,因为我真的很喜欢具有所有

不要没有标题是不敢接的想法;)

+0

*是不是不好中堂没有''

* - 这是完全正常的... ... *多个标题无效或?* - 完全有效 –

+0

多个标题有效吗?我想那对我来说是完美的,然后我做3''。 – redanimalwar

+0

是的,但是 - http://www.w3.org/TR/html-markup/header.html –

回答

2

如果它包含适合于header的内容,则确定每个分段根元素(例如,body)和每个分段内容元素(例如article)。该规范defines,它是对“介绍的内容”,并给出了下面的例子:

  • 介绍或导航辅助
  • 标题(一个h1 - h6元)(不需要)的内容
  • 表,搜索表单或任何相关徽标

如果存在此类内容,请使用header元素。如果该分段的根/内容元素中的内容分散,则使用多个header元素。记住

保持了header始终适用于“其最近的祖先切片的内容或切片根元素”:

<body> 
    <header> <!-- this header is for the whole page --> </header> 

    <article> 
    <header> <!-- this header is for the whole article element --> </header> 

    <div> 
     <header> <!-- this header is also for the whole article element (and not only for the div element!) --></header> 
    </div> 

    <section> 
     <header> <!-- this header is for this article’s section element only --> </header> 
    </section> 

    </article> 

    <figure> 
    <header> <!-- this header is for the figure element only --> </header> 
    </figure> 

    <strong> 
    <header> <!-- but this header is also for the whole page (and not for the strong element only!) --> </header> 
    </strong> 

</body> 
+0

我已经知道这一切,我决定选择我的第二个解决方案。 – redanimalwar