diff --git a/core/includes/form.inc b/core/includes/form.inc
index 1408dbe5e24..af1950aef6b 100644
--- a/core/includes/form.inc
+++ b/core/includes/form.inc
@@ -2832,10 +2832,15 @@ function theme_fieldset($variables) {
$element['#attributes']['aria-describedby'] = $description_id;
}
+ $legend_attributes = array();
+ if (isset($element['#title_display']) && $element['#title_display'] == 'invisible') {
+ $legend_attributes['class'][] = 'element-invisible';
+ }
+
$output = '