diff --git a/core/lib/Drupal/Component/Utility/Html.php b/core/lib/Drupal/Component/Utility/Html.php
index f9bb8e6a23aa8d3dbbe24ffd7e2d1ad9f7f00edd..8c7d3888cd7d0760b906f99bb280526e925ded5e 100644
--- a/core/lib/Drupal/Component/Utility/Html.php
+++ b/core/lib/Drupal/Component/Utility/Html.php
@@ -286,7 +286,7 @@ public static function load($html) {
 
     $dom = new \DOMDocument();
     // Ignore warnings during HTML soup loading.
-    @$dom->loadHTML($document);
+    @$dom->loadHTML($document, LIBXML_NOBLANKS);
 
     return $dom;
   }
diff --git a/core/misc/cspell/dictionary.txt b/core/misc/cspell/dictionary.txt
index 6b8c9fe60e3d01054a0a7415cfb9f09dd0b1e8e6..b141ad61b60572abb6cf4d4b5a3cbe85f78e2750 100644
--- a/core/misc/cspell/dictionary.txt
+++ b/core/misc/cspell/dictionary.txt
@@ -870,6 +870,7 @@ nmsgstr
 nntp
 noaccess
 noadd
+noblanks
 nocache
 nocase
 nocdata
diff --git a/core/tests/Drupal/KernelTests/AssertContentTrait.php b/core/tests/Drupal/KernelTests/AssertContentTrait.php
index fec10836ff08829fed64f183390ff22cd913f058..f145e0d1fd285f49fad9d2cecea5e89c08dae835 100644
--- a/core/tests/Drupal/KernelTests/AssertContentTrait.php
+++ b/core/tests/Drupal/KernelTests/AssertContentTrait.php
@@ -125,7 +125,7 @@ protected function parse() {
       // DOM can load HTML soup. But, HTML soup can throw warnings, suppress
       // them.
       $html_dom = new \DOMDocument();
-      @$html_dom->loadHTML('<?xml encoding="UTF-8">' . $this->getRawContent());
+      @$html_dom->loadHTML('<?xml encoding="UTF-8">' . $this->getRawContent(), LIBXML_NOBLANKS);
       if ($html_dom) {
         // It's much easier to work with simplexml than DOM, luckily enough
         // we can just simply import our DOM tree.