Html:h1 标签应该用于网站标题还是页面标题?
过去,我经常将网站标题放在
标记中,然后将主页标题放在
中。这是否被认为是正确的,或者主页标题应该位于
标记中?如果是这样,您将网站标题放在哪里?在常规
中?或者?
中。这是否被认为是正确的,或者主页标题应该位于
标记中?如果是这样,您将网站标题放在哪里?在常规
中?或者?
中?或者?在考虑可访问性等因素时,什么是语义上最正确的,什么是最好的?
In the past I have often put the site title in an <h1>
tag, and then the main page title in an <h2>
. Is this considered correct, or should the main page title be in the <h1>
tag? If so, where do you put the site title? In a regular <div>
? Or?
What is the most semantically correct, and what is the best when considering things like accessibility?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
没有真正的标准,并且存在相当多的不同意见。不过我同意 womp 的观点:你不应该在网站的每个页面上都有相同的 H1。我将网站标题保留为</code> 标记。
从语义上讲(为了帮助可访问性),普遍接受的规则是每页或主题一个
。一页上有多个顶级标题是有效的,只要这些标题将文档分成讨论不同事物的单独逻辑块即可。因此,以显示最近五篇文章的博客主页为例,每个文章都有自己的
就可以了。
然而,当涉及到 SEO 时,建议通常是每页只有一个 H1。
我在我的设计博客上采用了混合方法:在主页上,有一个 H1 描述了网站,每个帖子标题都是一个
。但是,在各个帖子页面上,帖子标题为
。到目前为止,这似乎在语义和搜索引擎优化之间取得了良好的平衡。
There's no real standard and there are quite a few differing opinions. I agree with womp though: you shouldn't have the same H1 on every page of the site. I'd leave the site title to the
<title>
tag.Semantically (and to aid accessibility), the generally accepted rule is one
<H1>
per page or topic. It's valid to have more than one top-level heading on a page, as long as those headings break the document into separate logical chunks discussing different things. So to take the example of a blog home page showing the five most recent articles, it would be fine for each to have its own<H1>
.However, when it comes to SEO, the recommendations are usually that you only have one H1 per page.
I've gone for a hybrid approach on my design blog: on the home page, there is an H1 describing the site, and each post title is an
<H2>
. However, on the individual post pages, the post title is the<H1>
. This seems (so far) to strike a good balance between semantics and optimising for search engines.在 Google 的 搜索引擎优化入门指南:
On page 20 of Google's Search Engine Optimization Starter Guide :
如果 H1 标签与页面上的大部分内容在上下文上相关,那就更好了 - 所以它实际上应该是页面标题。
如果每个页面都有相同的H1标签(即网站标题),就会降低它们的价值(总的来说,它们确实是最有价值的标签)。
如果您将网站标题放在标题中,而不是带有替代文本的图像,我通常只会设置 div 或 span 的样式。
It's better if H1 tags are contextually related to the majority of the content on the page - so it should really be the page title.
If every page has the same H1 tag (i.e. the site title), it degrades the value of them (and overall, they are really the most valuable tag).
If you're putting the site title in the header as something that's not an image with alt text, I would usually just style up a div or a span.