使用< h1>在HTML5中的网站名称 [英] Using <h1> on website name in HTML5

查看:93
本文介绍了使用< h1>在HTML5中的网站名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在HTML5中正确标记网站的标题?通常我用以下标记来标记网站的名称:

 < h1> 
< a href =#>网站名称< / a>
< / h1>

最近我遇到了HTML5文档大纲算法。我还读到,似乎在h1标签中标记您的网站名称没有意义,因为除了网站名称之外,每个页面可能都有不同的主标题(h1)。



如果Facebook的标识/标题的标记包含在< h1> 标记中,那么如果让我说在Facebook上怎么办?然后,如果每篇文章都包装在< article> 标签中。例如:

 < article class =post> 
< h5 class =post-header>
< a href =#>有人分享了Blah Blah的照片< / a>
< / h5>
< div class =post-body> ...< / div>
< / article>

我认为文档大纲是


  1. Facebook



    1.1有人分享了Blah Blah的照片

    1.2其他帖子



    1.3其他帖子


可以吗?

解决方案

特别是因为的大纲,使用 h1



如果您的网页是网站的一部分,每个网页都应该有一个网站标题 h1 ,其中包含该网站标题,网站标志或两者兼而有之。这是非常重要的,这个网站的标题是不是元素的一个子元素( section / article / 抛开 / nav )。 顶级页面标题始终是网站标题。而网站导航,网页的主要内容,辅助内容的侧边栏等都将成为该顶层标题的小孩。因此,一个简单的结构博客帖子页面可能是:

 < body> 
< h1>< img src =logo.pngalt =John's blog>< / h1>

< nav><! - 网站范围内的导航 - >< / nav>

< article>
< h1>我的第一篇博文< / h1>
< p> ...< / p>
< footer><! - 此页脚仅适用于文章 - >< / footer>
< / article>

< footer><! - 此页脚适用于整个页面(→站点) - >< / footer>

< / body>

这将创建一个大纲:

 1.1无标题(→body> nav)
1.2我的第一篇博文(→body> class =lang-none prettyprint-override> ;文章> h1)

如果您不在<$ c $中使用网站标题/徽标c> h1 ,页面将有一个无标题的顶层轮廓条目:

 <$ c $ (→body>文章> h1)

1.1 pre>

如果您不使用 h1 作为网站标题/徽标和 em>您的主要内容没有分区元素...


$ b

 < body> 
< img src =logo.pngalt =John的博客> <! - 省略h1 - >

< nav><! - 网站范围内的导航 - >< / nav>

<! - 省略文章 - >
< h1>我的第一篇博文< / h1>
< p> ...< / p>

< / body>

...您将获得包含两个顶级条目的大纲:

1无标题(→body)
1.1无标题(→body> nav)
2我的第一篇博客发布(→正文> h1)


How to properly markup the title of a site in HTML5? Usually I markup a website's name with:

<h1>
    <a href=#>Website Name</a>
</h1>

Recently I've come across with the HTML5 Document Outlining Algorithm. I have also read that it seems like marking your site's name in h1 tag don't make sense, since every page probably will have different main heading (h1), in addition to the website name.

What if let's say on Facebook, if the markup of the Facebook's logo/title is wrapped in <h1> tag. Then if every post is wrapped in <article> tags. For example:

<article class="post">
    <h5 class="post-header">
         <a href="#">Someone has shared Blah Blah's photo</a>
    </h5>
     <div class="post-body">...</div>
</article>

I think the document outline would be

  1. Facebook

    1.1 Someone has shared Blah Blah's photo

    1.2 Other Posts

    1.3 Other Posts

Is that okay?

解决方案

Especially because of the outline it makes sense to use h1.

If your webpage is part of a website, each page should have a site header h1, which contains the site title, the site logo, or both. It's important that this site header is not a child of a sectioning element (section/article/aside/nav).

So the toplevel heading for a page will always be the site heading. And the site navigation, the main content of the page, sidebars with secondary content etc. will all be "children" of that toplevel heading.

So a simple structure for a blog post page could be:

<body>
  <h1><img src="logo.png" alt="John's blog"></h1>

  <nav><!-- the site-wide navigation --></nav> 

  <article>
    <h1>My first blog post</h1>
    <p>…</p>
    <footer><!-- this footer applies to the article only--></footer>
  </article>

  <footer><!-- this footer applies to the whole page (→ the site)--></footer>

</body> 

This would create an outline like:

1 John's blog (→ body>h1)
  1.1 untitled (→ body>nav)
  1.2 My first blog post (→ body>article>h1)

If you wouldn't use the site title/logo in h1, the page would have an untitled toplevel outline entry:

1 untitled (→ body)
  1.1 untitled (→ body>nav)
  1.2 My first blog post (→ body>article>h1)

And if you wouldn't use a h1 for the site title/logo and no sectioning element for your main content …

<body>
  <img src="logo.png" alt="John's blog"> <!-- omitted h1 -->

  <nav><!-- the site-wide navigation --></nav> 

  <!-- omitted article -->
  <h1>My first blog post</h1>
  <p>…</p>

</body> 

… you’d get an outline with two top-level entries:

1 untitled (→ body)
  1.1 untitled (→ body>nav)
2 My first blog post (→ body>h1)

这篇关于使用&lt; h1&gt;在HTML5中的网站名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆