!DOCTYPE html destroyed page

175 Views Asked by At

I have strange bug with !DOCTYPE html.

When I'm trying to use HTML5 Doctype, then my page looks weird. All scripts looks like not closed properly.

But when I'm changing to !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd", then everything looks good.

I don't understand what's wrong with page structure and why it's happened only with HTML5.

2

There are 2 best solutions below

0
Donnie On BEST ANSWER

Thank you guys, for your help!

I found how I can solve it. In my case, error was in one extension, which used $dom->saveXML() method in observer. And before rendering this method parsed DOM and removed/replaced HTML output.

5
James Donnelly On

HTML5 completely removed and reworked many HTML4 elements (which XHTML 1.0 is based on). If a website is coded primarily in XHTML 1.0, you can't just switch over to HTML5 and assume things won't break.

Your best option is to run your converted-doctype code through W3C's HTML validator at https://validator.w3.org and have a look through the errors and warnings which it generates. This should give you an idea of why things aren't working the way you want them to be.