How to protect layout from malformatted html content on a generated webpage?

202 Views Asked by At

I have a container layout of a webpage that works like this:

<html>
#header#
<div class="content_container"> #content inserted here# </div>
#footer#
</html>

If the content has a div that is not closed or closes a div without it being opened, the content_container's div and so the layout gets messed up.

How is this situation normally avoided or solved?

1

There are 1 best solutions below

0
On BEST ANSWER

Hy,

From what i found on the net, you could parse the fragment as a HTML document using the DOM loadHTML function, then spit it back out again as HTML. That will fix any HTML well-formedness errors.

Or you could use the Tidy extension for php5

http://www.php.net/tidy