I have the following code
<p>
<%= sanitize "<p>This is a test</p>" %>
</p>
I expected the sanitized html would show up between <p></p>. However it produces.
<p>
</p>
<p>This is a test</p>
When I change the enclosing <p></p> to <div></div>, the sanitized html shows up between <div></div> as I would expect.
Why does sanitizing html between <p></p> remove the sanitized html from the enclosing tag and place it after the enclosing tag?
How do I get the the sanitized html to show up in <p></p>?
Nesting paragraph tags is not legal; the
<p>tag only accepts phrasing content tags.This is why the Chrome dev tools show a changed order - the browser is correcting the mistake as good as it can and moves the inner
<p>out and next to it.