diff --git a/core/includes/theme.inc b/core/includes/theme.inc
index 4c0e580..8b9eec5 100644
--- a/core/includes/theme.inc
+++ b/core/includes/theme.inc
@@ -2758,7 +2758,7 @@ function template_preprocess_html(&$variables) {
     }
   }
   $variables['head_title_array'] = $head_title;
-  $variables['head_title'] = implode(' | ', $head_title);
+  $variables['head_title'] = strip_tags(implode(' | ', $head_title));
 
   // Display the html.tpl.php's default mobile metatags for responsive design.
   $elements = array(
@@ -3050,7 +3050,7 @@ function template_preprocess_maintenance_page(&$variables) {
   }
 
   $variables['head_title_array']  = $head_title;
-  $variables['head_title']        = implode(' | ', $head_title);
+  $variables['head_title']        = strip_tags(implode(' | ', $head_title));
   $variables['base_path']         = base_path();
   $variables['front_page']        = url();
   $variables['breadcrumb']        = '';
diff --git a/core/modules/system/lib/Drupal/system/Tests/System/PageTitleFilteringTest.php b/core/modules/system/lib/Drupal/system/Tests/System/PageTitleFilteringTest.php
index 7e89cf7..cfb81ea 100644
--- a/core/modules/system/lib/Drupal/system/Tests/System/PageTitleFilteringTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/System/PageTitleFilteringTest.php
@@ -82,6 +82,32 @@ function testTitleTags() {
     $this->drupalGet("node/" . $node->nid);
     $this->assertText(check_plain($edit["title"]), 'Check to make sure tags in the node title are converted.');
   }
+
+  /**
+   * Tests the handling of site-name and slogan markup in HTML title tag
+   */
+  function testHTMLTitleTag() {
+    $sitename = "drupal with <3";
+    $slogan = "slogan containing <em>HTML tags</em>";
+
+    // Set site-name and slogan for front page
+    $edit = array(
+      'site_name'    => $sitename,
+      'site_slogan'  => $slogan,
+    );
+    $this->drupalPost('admin/config/system/site-information', $edit, t('Save configuration'));
+
+    // Create a promoted node so we don't get 'Welcome to @site-name' but the slogan.
+    $this->drupalCreateNode(array('type' => 'page', 'promote' => 1));
+
+    // test title tag for tags and entities
+    $this->drupalGet('');
+    $title = (string) current($this->xpath('//title'));
+    $this->assertTrue(strpos($title, strip_tags($slogan)) !== FALSE, t('HTML title tag contains the slogan with markup stripped.'));
+    $this->assertTrue(strpos($title, '<em>') === FALSE, t('HTML title tag must not contain markup.'));
+    $this->assertTrue(strpos($title, '&amp;em&amp;') === FALSE, t('HTML title tag is stripped of tags (i.e.no entities).'));
+  }
+
   /**
    * Test if the title of the site is XSS proof.
    */
