在HTML5中使用H1徽标 [英] Using a H1 logo in HTML5
问题描述
带图像的h1标签辩论似乎与时间本身一样古老,但与 据我所知,以下内容适用于 HTML OA : 但是我正在一家网站上与一家SEO公司合作,他们告诉我: p> 徽标链接不能是H1,没有意义。 他们是对的吗?上面的文档大纲有什么不好的地方?如果您不能将徽标放在H1标签中,为什么 W3C自己在自己的网站上? 这些人据说是SEO专家,但我不明白他们的抱怨。我错过了什么? 是的,您可以有 如果您的网站没有显示单独的文本名称,您绝对应该这样做。否则,文档大纲可能是错误的(如果您不需要在任何需要的地方使用分区元素),或者至少大纲会有一个未标记的顶层条目,这不是非常用户友好/可访问的。 如果您有站点徽标和为文本网站名称,则可以讨论:将 有关示例,请参阅我的一些相关答案( 1 , 2 , 3 )和代码审查( 1 ,2 , 3 )。 (您的SEO专家并不是唯一有此问题的人,正如您在我的链接答案的某些评论中可以看到的那样。我还没有看到反对它的论据...)。 The "h1 tag with an image" debate seems as old as time itself, but with HTML5 explicitly allowing multiple H1 tags as part of its spec, all the previous questions on this subject seem out of date. As I understand it, the following works perfectly with the HTML OA: But I'm working with an SEO company on a website and they've told me: "The logo link CAN’T be H1. It doesn’t make sense." Are they right? Is there something bad about the above document outline? If you can't put the logo in a H1 tag, why do the W3C do it themselves on their website? These people are supposedly SEO experts, but I just don't understand their complaint. What am I missing? Yes, you can have an If your site doesn’t show a separate textual name, you definitely should do this. Otherwise, the document outline could be wrong (if you don’t use sectioning elements wherever needed) or at least the outline would have an unlabeled top-level entry, which is not very user friendly/accessible. If you have a site logo and a textual site name, it’s discussible: either include the For examples, see some of my related answers on SO (1, 2, 3) and Code Review (1, 2, 3). (Your "SEO expert" is not the only one having a problem with this, as you can see in some of the comments to my linked answers. I have yet to see an argument against it ….) 这篇关于在HTML5中使用H1徽标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
< body>
< header>
< h1>
< a href =http://www.example.com>
< img src =logo.pngalt =厄尼餐厅 - 意大利美食>
< / a>
< / h1>
< / header>
< nav><! - 全站导航 - >< / nav>
<文章>
< h1>关于我们< / h1>
< p> ...< / p>
< / article>
< / body>
img
元素作为 h1
元素的内容。
是的,将 img
-logo作为 h1
(以防它属于 body
sectioning root,就像它在你的例子中一样)。
img
与文本在同一个 h1
中,或者只有 h1
中的一个元素(任何一个都可能)另一个为替代标题,例如,一起放入标题中
元素。
<body>
<header>
<h1>
<a href="http://www.example.com">
<img src="logo.png" alt="Ernie's Restaurant - Great Italian food">
</a>
</h1>
</header>
<nav><!-- the site-wide navigation --></nav>
<article>
<h1>About us</h1>
<p>…</p>
</article>
</body>
img
element as content of an h1
element.
Yes, it makes sense to have the img
-logo as h1
(in case it belongs to the body
sectioning root, like it does in your example).img
together with the text in the same h1
, or have only one of these elements in h1
(either one is possible) and have the other one as "alternative title", e.g., together in a header
element.