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

In my HTMLPHP code I have the following piece of code which makes sure the filtering is removed from a

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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744692256a4588278.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信