Hugo
Hugo

Reputation: 767

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.

<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

Upvotes: 1

Views: 9467

Answers (1)

dsgriffin
dsgriffin

Reputation: 68596

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.

Upvotes: 4

Related Questions