diff --git a/core/modules/filter/filter.filter_html.admin.es6.js b/core/modules/filter/filter.filter_html.admin.es6.js
index c5809c09e8..b196008f2f 100644
--- a/core/modules/filter/filter.filter_html.admin.es6.js
+++ b/core/modules/filter/filter.filter_html.admin.es6.js
@@ -231,13 +231,32 @@
       let rule;
       let attributes;
       let attribute;
+      let currentTag;
       const allowedTags = setting.match(/(<[^>]+>)/g);
       const sandbox = document.createElement('div');
       const rules = {};
       for (let t = 0; t < allowedTags.length; t++) {
         // Let the browser do the parsing work for us.
-        sandbox.innerHTML = allowedTags[t];
-        node = sandbox.firstChild;
+        currentTag = allowedTags[t];
+        // Table tags need to be wrapped in a <table>.
+        if (['<caption>', '<tbody>', '<thead>', '<tfoot>', '<th>', '<td>', '<tr>'].indexOf(currentTag) === -1) {
+          sandbox.innerHTML = currentTag;
+          node = sandbox.firstChild;
+        }
+        else {
+          sandbox.innerHTML = '<table>' + currentTag;
+          switch (currentTag) {
+            case '<th>':
+            case '<td>':
+              node = sandbox.firstChild.firstChild.firstChild.firstChild;
+              break;
+            case '<tr>':
+              node = sandbox.firstChild.firstChild.firstChild;
+              break;
+            default:
+              node = sandbox.firstChild.firstChild;
+          }
+        }
         tag = node.tagName.toLowerCase();
 
         // Build the Drupal.FilterHtmlRule object.
diff --git a/core/modules/filter/filter.filter_html.admin.js b/core/modules/filter/filter.filter_html.admin.js
index 773f35a9d8..0972f89c26 100644
--- a/core/modules/filter/filter.filter_html.admin.js
+++ b/core/modules/filter/filter.filter_html.admin.js
@@ -136,12 +136,30 @@
       var rule = void 0;
       var attributes = void 0;
       var attribute = void 0;
+      var currentTag = void 0;
       var allowedTags = setting.match(/(<[^>]+>)/g);
       var sandbox = document.createElement('div');
       var rules = {};
       for (var t = 0; t < allowedTags.length; t++) {
-        sandbox.innerHTML = allowedTags[t];
-        node = sandbox.firstChild;
+        currentTag = allowedTags[t];
+
+        if (['<caption>', '<tbody>', '<thead>', '<tfoot>', '<th>', '<td>', '<tr>'].indexOf(currentTag) === -1) {
+          sandbox.innerHTML = currentTag;
+          node = sandbox.firstChild;
+        } else {
+          sandbox.innerHTML = '<table>' + currentTag;
+          switch (currentTag) {
+            case '<th>':
+            case '<td>':
+              node = sandbox.firstChild.firstChild.firstChild.firstChild;
+              break;
+            case '<tr>':
+              node = sandbox.firstChild.firstChild.firstChild;
+              break;
+            default:
+              node = sandbox.firstChild.firstChild;
+          }
+        }
         tag = node.tagName.toLowerCase();
 
         rule = new Drupal.FilterHTMLRule();
