HTML5验证的空白标题警告 [英] Empty heading warning on HTML5 validation
问题描述
I try to validate my HTML code and I have found this warning: Empty heading. See here
显然,标题不是空的. <h3></h3>
的内容是在WordPress中通过the_title()
函数生成的.所以,我不明白为什么会这样.有人可以向我解释是什么问题?谢谢!
Obviously the heading is not empty. The content of the <h3></h3>
is generated, in WordPress, by the_title()
function. So, I don't understand why is this happen.. Somebody can explain me what is the problem? Thanks!
推荐答案
首先,HTML是有效的.它通过了W3C检查,因此您不必太担心 .
First off, the HTML is valid. It passes the W3C check, so you don't need to worry too much.
话虽如此,您的代码 滥用HTML语法. 空标题"警告表示您的标题标签(<hN>
)没有与之关联的任何内容.标题标签的意思是这就是这部分内容的含义". 如HTML5规范所述:
With that said, your code is misusing HTML syntax. The "empty heading" warning means that you have a heading tag (<hN>
) that doesn't have any content associated with it. Heading tags are intended to mean "this is what this bit of content is about". As the HTML5 spec says:
h1
至h6
元素是与它们关联的部分的标题.
The
h1
throughh6
elements are headings for the sections with which they are associated.
您将使用h3
标记作为格式说明.它没有关联的内容;这些单词实际上并不是任何内容的标题.这是在滥用标签的语义.
You are instead using the h3
tag as a formatting instruction. It has no content associated; the words are not actually the header for any content. This is misusing the semantics of the tag.
这有关系吗?可能不是,尽管依赖HTML语义而不是外观的软件(例如屏幕阅读器)可能会发现它很棘手.我不确定Wordpress的工作方式-仍然很难修复.
Does this matter? Probably not, though software which relies on the semantics of HTML rather than the appearance (e.g. screenreaders) might find it tricky. I'm not sure about how Wordpress works -- it might be very difficult to fix anyway.
这篇关于HTML5验证的空白标题警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!