最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - W3C error: document type does not allow element X here; missing one of Y start-tag - Stack Overflow

programmeradmin0浏览0评论

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.

<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. 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:

document type does not allow element "p" here; missing one of "object", "applet", "map", "iframe", "button", "ins", "del" 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.

<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. 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:

document type does not allow element "p" here; missing one of "object", "applet", "map", "iframe", "button", "ins", "del" start-tag

Share Improve this question edited Apr 25, 2013 at 13:30 dsgriffin 68.7k17 gold badges140 silver badges138 bronze badges asked Apr 24, 2013 at 14:14 HugoHugo 7671 gold badge13 silver badges24 bronze badges 1
  • 1 Paragraphs are not allowed in headings? – Bergi Commented Apr 24, 2013 at 14:16
Add a ment  | 

1 Answer 1

Reset to default 4

HTML4:

You're recieving an error because it isn't valid mark-up. You can't include <p> tags inside <h2> tags.

You can however, use elements such as <span> inside heading tags as they are inline.

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:

As of HTML5, It is still invalid to have paragraphs inside heading tags, according to the HTML5 specification.

发布评论

评论列表(0)

  1. 暂无评论