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:
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 1document type does not allow element "p" here; missing one of "object", "applet", "map", "iframe", "button", "ins", "del" start-tag
- 1 Paragraphs are not allowed in headings? – Bergi Commented Apr 24, 2013 at 14:16
1 Answer
Reset to default 4HTML4:
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.