[英]W3C error: document type does not allow element X here; missing one of Y start-tag
In my HTML/PHP code I have the following piece of code which makes sure the filtering is removed from a group of fields with JavaScript. 在我的HTML / PHP代码中,我有以下代码,确保使用JavaScript从一组字段中删除过滤。
<form id="prices" action="">
<div class="box searchPrices" id="pricesDiv">
<h2>Prijzen
<p class="removeAll" rel="prices"></p>
<span></span>
</h2>
...
</div>
</form>
This works as expected, but now my W3C validation is not validating correctly anymore. 这按预期工作,但现在我的W3C验证不再正确验证。 Is there a nice way to go around this caveat to make sure it validates nicely and still removes the filtering?
有没有一个很好的方法绕过这个警告,以确保它很好地验证,仍然删除过滤?
The W3C error I get: 我得到的W3C错误:
document type does not allow element "p" here;
文档类型不允许元素“p”; missing one of "object", "applet", "map", "iframe", "button", "ins", "del" start-tag
缺少“object”,“applet”,“map”,“iframe”,“button”,“ins”,“del”start-tag
HTML4: HTML4:
You're recieving an error because it isn't valid mark-up. 您收到错误,因为它不是有效的标记。 You can't include
<p>
tags inside <h2>
tags. 您不能在
<h2>
标记内包含<p>
<h2>
标记。
You can however, use elements such as <span>
inside heading tags as they are inline. 但是,您可以在标题标记内使用
<span>
等元素,因为它们是内联的。
Take a look at the relevant specification section here - navigate around and you'll find which elements are allowed where etc (basically, all entities under the special section). 在这里查看相关的规范部分 - 浏览并找到允许哪些元素等(基本上, 特殊部分下的所有实体)。
HTML5: HTML5:
As of HTML5, It is still invalid to have paragraphs inside heading tags, according to the HTML5 specification . 从HTML5开始,根据HTML5规范 , 在标题标记内包含段落 仍然无效 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.