diff --git a/src/client/conversation-viewer/conversation-viewer.vala b/src/client/conversation-viewer/conversation-viewer.vala
index d81fb1c..2199311 100644
--- a/src/client/conversation-viewer/conversation-viewer.vala
+++ b/src/client/conversation-viewer/conversation-viewer.vala
@@ -487,7 +487,6 @@ public class ConversationViewer : Gtk.Box {
         try {
             div_message = make_email_div();
             div_message.set_attribute("id", message_id);
-            web_view.container.insert_before(div_message, insert_before);
             if (email.is_unread() == Geary.Trillian.FALSE) {
                 div_message.get_class_list().add("hide");
             }
@@ -504,6 +503,7 @@ public class ConversationViewer : Gtk.Box {
         bool remote_images = false;
         try {
             set_message_html(email.get_message(), div_message, out remote_images);
+            web_view.container.insert_before(div_message, insert_before);
         } catch (Error error) {
             warning("Error getting message from email: %s", error.message);
         }
@@ -619,6 +619,48 @@ public class ConversationViewer : Gtk.Box {
         // </div>
         return Util.DOM.clone_select(web_view.get_dom_document(), "#email_template");
     }
+
+    private string sanitize_style(string style, string div_message_id) {
+        try {
+            // matches "string" or 'string'
+            string string_re = """(?:"(?:[^"\\]+|\\.)*+"|'(?:[^'\\]+|\\.)*+')"""; 
+
+            // matches strings, normal characters or escaped characters until
+            // encountering a raw {
+            string selectors_re = """(?:[^{"'\\]++|\\.|"""+string_re+""")*+"""; 
+
+            // matches strings, normal characters or escaped charcters until
+            // encountering ar raw }
+            string body_re = """(?:[^}"'\\]++|\\.|"""+string_re+""")*+""";
+
+            string scope = "html>body>#message_container>" +
+                "div[id=\"" + div_message_id + "\"]>" + 
+                ".email_container>.body" ;
+            
+            Regex style_re = new Regex("(" + selectors_re + "){(" + body_re + ")}",
+                RegexCompileFlags.DOTALL);
+            Regex comment_re = new Regex("""/\*(?:[^*]*+|\*[^/])*+\*/""", RegexCompileFlags.DOTALL);
+
+            return style_re.replace_eval(comment_re.replace(style, -1, 0, ""), -1, 0, 0, 
+                (match, result) => {
+                    bool first = true;
+                    foreach(string selector in match.fetch(1).split(",")) {
+                        result.append(first ? "\n" : ", ");
+                        result.append(" " + scope + " " + selector.strip());
+                        first = false;
+                    }
+                    result.append("{");
+                    result.append(match.fetch(2));
+                    result.append("}");
+                    return false;
+                }
+            );
+        } catch (RegexError e) {
+            // Invalid CSS syntax, probably SASS/LESS, just drop it.
+            warning("Can't sanitize CSS: %s", e.message);
+            return "";
+        }
+    }
     
     private void set_message_html(Geary.RFC822.Message message, WebKit.DOM.HTMLElement div_message,
         out bool remote_images) {
@@ -689,6 +731,21 @@ public class ConversationViewer : Gtk.Box {
             warning("Error setting HTML for message: %s", html_error.message);
         }
 
+        // Scope <style> tags
+        // TODO: use Shadow DOM or <style scoped> once it's available in WebKitGTK
+        try {
+            WebKit.DOM.NodeList styles = div_email_container.query_selector_all("style");
+            for(int i = 0; i < styles.length; i++) {
+                if (styles.item(i) is WebKit.DOM.HTMLElement) {
+                    WebKit.DOM.HTMLElement style = styles.item(i) as WebKit.DOM.HTMLElement;
+                    style.set_inner_html(sanitize_style(style.get_inner_html(),
+                        div_message.get_attribute("id")));
+                }
+            }
+        } catch(Error html_error) {
+            warning("Error sanitizing CSS: %s", html_error.message);
+        }
+
         // Look for any attached emails
         Gee.List<Geary.RFC822.Message> sub_messages = message.get_sub_messages();
         foreach (Geary.RFC822.Message sub_message in sub_messages) {
