diff --git a/core/modules/views/templates/views-view-grid.html.twig b/core/modules/views/templates/views-view-grid.html.twig
index f2b155218e5a601cebba4a86deaa0d5fb73d60b6..b1aab93c5cbf7fb6dbe649e3ef017c7335b266b5 100644
--- a/core/modules/views/templates/views-view-grid.html.twig
+++ b/core/modules/views/templates/views-view-grid.html.twig
@@ -59,7 +59,7 @@
       <div{{ row.attributes.addClass(row_classes, options.row_class_default ? 'row-' ~ loop.index) }}>
         {% for column in row.content %}
           <div{{ column.attributes.addClass(col_classes, options.col_class_default ? 'col-' ~ loop.index) }}>
-            {{ column.content }}
+            {{- column.content -}}
           </div>
         {% endfor %}
       </div>
@@ -69,7 +69,7 @@
       <div{{ column.attributes.addClass(col_classes, options.col_class_default ? 'col-' ~ loop.index) }}>
         {% for row in column.content %}
           <div{{ row.attributes.addClass(row_classes, options.row_class_default ? 'row-' ~ loop.index) }}>
-            {{ row.content }}
+            {{- row.content -}}
           </div>
         {% endfor %}
       </div>
diff --git a/core/modules/views/templates/views-view-list.html.twig b/core/modules/views/templates/views-view-list.html.twig
index 8de787cd4bd9b65c005ddafe04fb3272b9fc4b87..558b31a28d70a71dbed2ce0f15ec379338577bc1 100644
--- a/core/modules/views/templates/views-view-list.html.twig
+++ b/core/modules/views/templates/views-view-list.html.twig
@@ -28,7 +28,9 @@
   <{{ list.type }}{{ list.attributes }}>
 
     {% for row in rows %}
-      <li{{ row.attributes }}>{{ row.content }}</li>
+      <li{{ row.attributes }}>
+        {{- row.content -}}
+      </li>
     {% endfor %}
 
   </{{ list.type }}>
diff --git a/core/modules/views/templates/views-view-unformatted.html.twig b/core/modules/views/templates/views-view-unformatted.html.twig
index 7ee1f81e5bc834d31b29f2a0141dbc3e486129f6..b67b5f7d7ce956ba82f025c2cc9416b5c8e43b30 100644
--- a/core/modules/views/templates/views-view-unformatted.html.twig
+++ b/core/modules/views/templates/views-view-unformatted.html.twig
@@ -27,6 +27,6 @@
     ]
   %}
   <div{{ row.attributes.addClass(row_classes) }}>
-    {{ row.content }}
+    {{- row.content -}}
   </div>
 {% endfor %}
diff --git a/core/modules/views/tests/modules/views_test_data/views_test_data.views_execution.inc b/core/modules/views/tests/modules/views_test_data/views_test_data.views_execution.inc
index dd69f4c95fbcd30b4842c469a85f8e99697d4056..8eaa704a188bbb52deecab2c74c26b14267cbcf7 100644
--- a/core/modules/views/tests/modules/views_test_data/views_test_data.views_execution.inc
+++ b/core/modules/views/tests/modules/views_test_data/views_test_data.views_execution.inc
@@ -74,6 +74,11 @@ function views_test_data_placeholders() {
  */
 function views_test_data_views_post_render(ViewExecutable $view, &$output, CachePluginBase $cache) {
   \Drupal::state()->set('views_hook_test_views_post_render', TRUE);
+  if ($view->storage->id() === 'test_page_display' && $view->current_display === 'empty_row') {
+    for ($i = 0; $i < 5; $i++) {
+      $output['#rows'][0]['#rows'][] = [];
+    }
+  }
 }
 
 /**
diff --git a/core/modules/views/tests/src/Kernel/Plugin/DisplayPageTest.php b/core/modules/views/tests/src/Kernel/Plugin/DisplayPageTest.php
index e420ea77c3d1e4d6259bbec564e48094e13e9a33..3904cdb490cdc3c555d3339e29310b94a6902c54 100644
--- a/core/modules/views/tests/src/Kernel/Plugin/DisplayPageTest.php
+++ b/core/modules/views/tests/src/Kernel/Plugin/DisplayPageTest.php
@@ -30,7 +30,7 @@ class DisplayPageTest extends ViewsKernelTestBase {
    *
    * @var array
    */
-  public static $modules = ['system', 'user', 'field'];
+  public static $modules = ['system', 'user', 'field', 'views_test_data'];
 
   /**
    * The router dumper to get all routes.
@@ -220,4 +220,40 @@ public function testReadMore() {
     $this->assertTrue($view->getDisplay()->getOption('use_more_always'), 'Always display the more link by default.');
   }
 
+  /**
+   * Tests the templates with empty rows.
+   */
+  public function testEmptyRow() {
+    $view = Views::getView('test_page_display');
+    $view->initDisplay();
+    $view->newDisplay('page', 'Page', 'empty_row');
+    $view->save();
+
+    $styles = [
+      'default' => '//div[@class="views-row"]',
+      'grid' => '//div[contains(@class, "views-col")]',
+      'html_list' => '//div[@class="item-list"]//li',
+    ];
+
+    $themes = ['bartik', 'classy', 'seven', 'stable', 'stark'];
+
+    foreach ($themes as $theme) {
+      \Drupal::service('theme_handler')->install([$theme]);
+      \Drupal::theme()->setActiveTheme(\Drupal::service('theme.initialization')->initTheme($theme));
+      foreach ($styles as $type => $xpath) {
+        $view = Views::getView('test_page_display');
+        $view->storage->invalidateCaches();
+        $view->initDisplay();
+        $view->setDisplay('empty_row');
+        $view->displayHandlers->get('empty_row')->default_display->options['style']['type'] = $type;
+        $view->initStyle();
+        $this->executeView($view);
+        $output = $view->preview();
+        $output = \Drupal::service('renderer')->renderRoot($output);
+        $this->setRawContent($output);
+        $this->assertCount(5, $this->xpath("{$xpath}[not(text()) and not(node())]"), "Empty rows in theme '$theme', type '$type'.");
+      }
+    }
+  }
+
 }
diff --git a/core/themes/classy/templates/views/views-view-grid.html.twig b/core/themes/classy/templates/views/views-view-grid.html.twig
index 2fe3028c9304b1a1c00a183c9b68e47a498aee2f..8a3a20bbfbcb33eeee42a8d220e12435574df08f 100644
--- a/core/themes/classy/templates/views/views-view-grid.html.twig
+++ b/core/themes/classy/templates/views/views-view-grid.html.twig
@@ -57,7 +57,7 @@
       <div{{ row.attributes.addClass(row_classes, options.row_class_default ? 'row-' ~ loop.index) }}>
         {% for column in row.content %}
           <div{{ column.attributes.addClass(col_classes, options.col_class_default ? 'col-' ~ loop.index) }}>
-            {{ column.content }}
+            {{- column.content -}}
           </div>
         {% endfor %}
       </div>
@@ -67,7 +67,7 @@
       <div{{ column.attributes.addClass(col_classes, options.col_class_default ? 'col-' ~ loop.index) }}>
         {% for row in column.content %}
           <div{{ row.attributes.addClass(row_classes, options.row_class_default ? 'row-' ~ loop.index) }}>
-            {{ row.content }}
+            {{- row.content -}}
           </div>
         {% endfor %}
       </div>
diff --git a/core/themes/classy/templates/views/views-view-list.html.twig b/core/themes/classy/templates/views/views-view-list.html.twig
index 44d4766d44b20d97b3480a289f01320855412a34..50cc74ba13fb0a8f922c2471cdce7c98246c9c01 100644
--- a/core/themes/classy/templates/views/views-view-list.html.twig
+++ b/core/themes/classy/templates/views/views-view-list.html.twig
@@ -26,7 +26,9 @@
   <{{ list.type }}{{ list.attributes }}>
 
     {% for row in rows %}
-      <li{{ row.attributes }}>{{ row.content }}</li>
+      <li{{ row.attributes }}>
+        {{- row.content -}}
+      </li>
     {% endfor %}
 
   </{{ list.type }}>
diff --git a/core/themes/classy/templates/views/views-view-unformatted.html.twig b/core/themes/classy/templates/views/views-view-unformatted.html.twig
index bece528c7a69ab9344b460cc66bb25bd2717e793..534ac9a95520d850af5b49adbc8c53124ffa11a5 100644
--- a/core/themes/classy/templates/views/views-view-unformatted.html.twig
+++ b/core/themes/classy/templates/views/views-view-unformatted.html.twig
@@ -25,6 +25,6 @@
     ]
   %}
   <div{{ row.attributes.addClass(row_classes) }}>
-    {{ row.content }}
+    {{- row.content -}}
   </div>
 {% endfor %}
diff --git a/core/themes/stable/templates/views/views-view-grid.html.twig b/core/themes/stable/templates/views/views-view-grid.html.twig
index 2fe3028c9304b1a1c00a183c9b68e47a498aee2f..8a3a20bbfbcb33eeee42a8d220e12435574df08f 100644
--- a/core/themes/stable/templates/views/views-view-grid.html.twig
+++ b/core/themes/stable/templates/views/views-view-grid.html.twig
@@ -57,7 +57,7 @@
       <div{{ row.attributes.addClass(row_classes, options.row_class_default ? 'row-' ~ loop.index) }}>
         {% for column in row.content %}
           <div{{ column.attributes.addClass(col_classes, options.col_class_default ? 'col-' ~ loop.index) }}>
-            {{ column.content }}
+            {{- column.content -}}
           </div>
         {% endfor %}
       </div>
@@ -67,7 +67,7 @@
       <div{{ column.attributes.addClass(col_classes, options.col_class_default ? 'col-' ~ loop.index) }}>
         {% for row in column.content %}
           <div{{ row.attributes.addClass(row_classes, options.row_class_default ? 'row-' ~ loop.index) }}>
-            {{ row.content }}
+            {{- row.content -}}
           </div>
         {% endfor %}
       </div>
diff --git a/core/themes/stable/templates/views/views-view-list.html.twig b/core/themes/stable/templates/views/views-view-list.html.twig
index 44d4766d44b20d97b3480a289f01320855412a34..50cc74ba13fb0a8f922c2471cdce7c98246c9c01 100644
--- a/core/themes/stable/templates/views/views-view-list.html.twig
+++ b/core/themes/stable/templates/views/views-view-list.html.twig
@@ -26,7 +26,9 @@
   <{{ list.type }}{{ list.attributes }}>
 
     {% for row in rows %}
-      <li{{ row.attributes }}>{{ row.content }}</li>
+      <li{{ row.attributes }}>
+        {{- row.content -}}
+      </li>
     {% endfor %}
 
   </{{ list.type }}>
diff --git a/core/themes/stable/templates/views/views-view-unformatted.html.twig b/core/themes/stable/templates/views/views-view-unformatted.html.twig
index bece528c7a69ab9344b460cc66bb25bd2717e793..534ac9a95520d850af5b49adbc8c53124ffa11a5 100644
--- a/core/themes/stable/templates/views/views-view-unformatted.html.twig
+++ b/core/themes/stable/templates/views/views-view-unformatted.html.twig
@@ -25,6 +25,6 @@
     ]
   %}
   <div{{ row.attributes.addClass(row_classes) }}>
-    {{ row.content }}
+    {{- row.content -}}
   </div>
 {% endfor %}