diff --git a/include/class.format.php b/include/class.format.php
index 5146c251e6b46e8d79ddab178b5480d611780342..539bf5f51d5cdc43565d6806f02a8e96a19611d3 100644
--- a/include/class.format.php
+++ b/include/class.format.php
@@ -207,8 +207,10 @@ class Format {
         // Remove HEAD and STYLE sections
         $html = preg_replace(
             array(':<(head|style).+</\1>:is',   # <head> and <style> sections
-                  ':<!\[[^]<]+\]>:'),           # <![if !mso]> and friends
-            array('', ''),
+                  ':<!\[[^]<]+\]>:',            # <![if !mso]> and friends
+                  ':<!DOCTYPE[^>]+>:',          # <!DOCTYPE ... >
+            ),
+            array('', '', ''),
             $html);
         $config = array(
             'safe' => 1, //Exclude applet, embed, iframe, object and script tags.