diff --git a/core/includes/form.inc b/core/includes/form.inc
index 85bffc6..0f15136 100644
--- a/core/includes/form.inc
+++ b/core/includes/form.inc
@@ -3957,6 +3957,10 @@ function theme_form_element($variables) {
   if (!empty($element['#attributes']['disabled'])) {
     $attributes['class'][] = 'form-disabled';
   }
+  // If #title is not set or not visible we add a class for styling.
+  if (!isset($element['#title']) || ($element['#title_display'] != 'before' && $element['#title_display'] != 'after')) {
+    $attributes['class'][] = 'form-label-none';
+  }
   $output = '<div' . new Attribute($attributes) . '>' . "\n";
 
   // If #title is not set, we don't display any label or required marker.
