diff --git a/core/modules/system/src/Form/SiteInformationForm.php b/core/modules/system/src/Form/SiteInformationForm.php
index a74545fa90..771b321565 100644
--- a/core/modules/system/src/Form/SiteInformationForm.php
+++ b/core/modules/system/src/Form/SiteInformationForm.php
@@ -109,6 +109,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
       '#title' => t('Slogan'),
       '#default_value' => $site_config->get('slogan'),
       '#description' => t("How this is used depends on your site's theme."),
+      '#maxlength' => 255,
     ];
     $form['site_information']['site_mail'] = [
       '#type' => 'email',
diff --git a/core/modules/system/tests/src/Functional/System/SiteInformationFormTest.php b/core/modules/system/tests/src/Functional/System/SiteInformationFormTest.php
new file mode 100644
index 0000000000..73ae3fc145
--- /dev/null
+++ b/core/modules/system/tests/src/Functional/System/SiteInformationFormTest.php
@@ -0,0 +1,49 @@
+<?php
+
+namespace Drupal\Tests\system\Functional\System;
+
+use Drupal\Tests\BrowserTestBase;
+
+/**
+ * @coversDefaultClass \Drupal\system\Form\SiteInformationForm
+ * @group system
+ */
+class SiteInformationFormTest extends BrowserTestBase {
+
+  /**
+   * {@inheritdoc}
+   */
+  protected $defaultTheme = 'stable';
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function setUp(): void {
+    parent::setUp();
+    $this->drupalLogin($this->drupalCreateUser(['administer site configuration', 'link to any page']));
+  }
+
+  /**
+   * Tests that the site slogan has the correct maxlength.
+   */
+  public function testSloganSize() {
+    $slogan_maxlength = 255;
+
+    $edit = [
+      'site_slogan' => $this->randomMachineName($slogan_maxlength),
+    ];
+    $this->drupalPostForm('admin/config/system/site-information', $edit, 'Save configuration');
+    $this->assertSession()->responseContains('The configuration options have been saved.');
+
+    $edit = [
+      'site_slogan' => $this->randomMachineName($slogan_maxlength + 1),
+    ];
+    $this->drupalPostForm('admin/config/system/site-information', $edit, 'Save configuration');
+    $placeholders = [
+      '%maxlength' => $slogan_maxlength,
+      '%out_of_size' => $slogan_maxlength + 1,
+    ];
+    $this->assertSession()->responseContains('Slogan cannot be longer than %maxlength characters but is currently %out_of_size characters long.', $placeholders);
+  }
+
+}
