diff --git a/core/modules/filter/filter.module b/core/modules/filter/filter.module
index 3fa834b..513b5d3 100644
--- a/core/modules/filter/filter.module
+++ b/core/modules/filter/filter.module
@@ -733,9 +733,6 @@ function _filter_tips($format_id, $long = FALSE) {
  */
 function template_preprocess_filter_guidelines(&$variables) {
   $format = $variables['format'];
-  $variables['attributes']['class'][] = 'filter-guidelines-item';
-  $variables['attributes']['class'][] = 'filter-guidelines-' . $format->format;
-
   $variables['tips'] = array(
     '#theme' => 'filter_tips',
     '#tips' => _filter_tips($format->format, FALSE),
@@ -752,9 +749,10 @@ function template_preprocess_filter_guidelines(&$variables) {
  *   - attributes: An associative array containing properties of the element.
  */
 function template_preprocess_text_format_wrapper(&$variables) {
+  $variables['description_class'] = FALSE;
   // Add element class and id for screen readers.
   if (isset($variables['attributes']['aria-describedby'])) {
-    $variables['attributes']['class'][] = 'description';
+    $variables['description_class'] = TRUE;
     $variables['attributes']['id'] = $variables['attributes']['aria-describedby'];
     // Remove aria-describedby attribute as it shouldn't be visible here.
     unset($variables['attributes']['aria-describedby']);
@@ -792,21 +790,11 @@ function template_preprocess_filter_tips(&$variables) {
 
   foreach ($variables['tips'] as $name => $tiplist) {
     foreach ($tiplist as $tip_key => $tip) {
-      $tiplist[$tip_key]['attributes'] = new Attribute(array());
-      if ($long) {
-        $tiplist[$tip_key]['attributes']['class'] = array('filter-' . str_replace("/", "-", $tip['id']));
-      }
+      $tiplist[$tip_key]['attributes'] = new Attribute();
     }
 
-    $attributes = array(
-      'class' => array(
-        'filter-type',
-        'filter-' . drupal_html_class($name),
-      ),
-    );
-
     $variables['tips'][$name] = array(
-      'attributes' => new Attribute($attributes),
+      'attributes' => new Attribute(),
       'name' => String::checkPlain($name),
       'list' => $tiplist,
     );
diff --git a/core/modules/filter/templates/filter-guidelines.html.twig b/core/modules/filter/templates/filter-guidelines.html.twig
index ecf9b94..4341349 100644
--- a/core/modules/filter/templates/filter-guidelines.html.twig
+++ b/core/modules/filter/templates/filter-guidelines.html.twig
@@ -19,7 +19,13 @@
  * @ingroup themeable
  */
 #}
-<div{{ attributes }}>
+{%
+  set classes = [
+    'filter-guidelines-item',
+    'filter-guidelines-' ~ format.format,
+  ]
+%}
+<div{{ attributes.addClass(classes) }}>
   <h4 class="label">{{ format.name }}</h4>
   {{ tips }}
 </div>
diff --git a/core/modules/filter/templates/filter-tips.html.twig b/core/modules/filter/templates/filter-tips.html.twig
index d8f70cb..b17de01 100644
--- a/core/modules/filter/templates/filter-tips.html.twig
+++ b/core/modules/filter/templates/filter-tips.html.twig
@@ -27,16 +27,27 @@
     <div class="compose-tips">
   {% endif %}
 
-  {% for tip in tips %}
+  {% for name, tip in tips %}
     {% if multiple %}
-      <div{{ tip.attributes }}>
+      {%
+        set tip_classes = [
+          'filter-type',
+          'filter-' ~ name|clean_class,
+        ]
+      %}
+      <div{{ tip.attributes.addClass(tip_classes) }}>
       <h3>{{ tip.name }}</h3>
     {% endif %}
 
     {% if tip.list|length %}
       <ul class="tips">
       {% for item in tip.list %}
-        <li{{ item.attributes }}>{{ item.tip }}</li>
+        {%
+          set item_classes = [
+            long ? 'filter-' ~ item.id|replace({'/': '-'}),
+          ]
+        %}
+        <li{{ item.attributes.addClass(item_classes) }}>{{ item.tip }}</li>
       {% endfor %}
       </ul>
     {% endif %}
diff --git a/core/modules/filter/templates/text-format-wrapper.html.twig b/core/modules/filter/templates/text-format-wrapper.html.twig
index b4ff1cc..607c38f 100644
--- a/core/modules/filter/templates/text-format-wrapper.html.twig
+++ b/core/modules/filter/templates/text-format-wrapper.html.twig
@@ -7,6 +7,8 @@
  * - children: Text format element children.
  * - description: Text format element description.
  * - attributes: HTML attributes for the containing element.
+ * - description_class: Flag for whether or not to add a class to the
+ *   description container.
  *
  * @see template_preprocess_text_format_wrapper()
  *
@@ -16,6 +18,11 @@
 <div class="text-format-wrapper form-item">
   {{ children }}
   {% if description %}
-    <div{{ attributes }}>{{ description }}</div>
+    {%
+      set classes = [
+        description_class ? 'description',
+      ]
+    %}
+    <div{{ attributes.addClass(classes) }}>{{ description }}</div>
   {% endif %}
 </div>
