diff --git a/templates/html.tpl.php b/templates/html.tpl.php
index 7e01c83..273d5f5 100644
--- a/templates/html.tpl.php
+++ b/templates/html.tpl.php
@@ -59,8 +59,16 @@
  * @see zen_preprocess_html()
  * @see template_process()
  */
+
+// Use a helper variable, so we use less code to create the html tag below.
+$html_attributes = 'lang="' . $language->language . '" dir="' . $language->dir . '"';
+
 ?><!DOCTYPE html>
-<html lang="<?php print $language->language; ?>" dir="<?php print $language->dir; ?>"<?php print $rdf_namespaces; ?>>
+<!--[if IEMobile 7]><html class="iem7" <?php print $html_attributes; ?>><![endif]-->
+<!--[if (lte IE 6)&(!IEMobile)]><html class="ie6 ie6-7 ie6-8" <?php print $html_attributes; ?>><![endif]-->
+<!--[if (IE 7)&(!IEMobile)]><html class="ie7 ie6-7 ie6-8" <?php print $html_attributes; ?>><![endif]-->
+<!--[if (IE 8)&(!IEMobile)]><html class="ie8 ie6-8" <?php print $html_attributes; ?>><![endif]-->
+<!--[if (gte IE 9)|(gt IEMobile 7)]><!--><html <?php print $html_attributes . $rdf_namespaces; ?>><!--<![endif]-->
 
 <head profile="<?php print $grddl_profile; ?>">
   <?php print $head; ?>
diff --git a/templates/maintenance-page.tpl.php b/templates/maintenance-page.tpl.php
index c60916a..7187405 100644
--- a/templates/maintenance-page.tpl.php
+++ b/templates/maintenance-page.tpl.php
@@ -9,9 +9,16 @@
  * @see template_preprocess()
  * @see template_preprocess_maintenance_page()
  */
-?>
-<!DOCTYPE html>
-<html lang="<?php print $language->language; ?>" dir="<?php print $language->dir; ?>">
+
+// Use a helper variable, so we use less code to create the html tag below.
+$html_attributes = 'lang="' . $language->language . '" dir="' . $language->dir . '"';
+
+?><!DOCTYPE html>
+<!--[if IEMobile 7]><html class="iem7" <?php print $html_attributes; ?>><![endif]-->
+<!--[if (lte IE 6)&(!IEMobile)]><html class="ie6 ie6-7 ie6-8" <?php print $html_attributes; ?>><![endif]-->
+<!--[if (IE 7)&(!IEMobile)]><html class="ie7 ie6-7 ie6-8" <?php print $html_attributes; ?>><![endif]-->
+<!--[if (IE 8)&(!IEMobile)]><html class="ie8 ie6-8" <?php print $html_attributes; ?>><![endif]-->
+<!--[if (gte IE 9)|(gt IEMobile 7)]><!--><html <?php print $html_attributes; ?>><!--<![endif]-->
 
 <head>
   <?php print $head; ?>
