Index: webform.module
===================================================================
--- webform.module	(revision 1359)
+++ webform.module	(working copy)
@@ -2393,30 +2393,60 @@
   }
   $prefix = isset($element['#field_prefix']) ? '<span class="field-prefix">' . _webform_filter_xss($element['#field_prefix']) . '</span> ' : '';
   $suffix = isset($element['#field_suffix']) ? ' <span class="field-suffix">' . _webform_filter_xss($element['#field_suffix']) . '</span>' : '';
+  $children = ' ' . $prefix . $element['#children'] . $suffix;
 
+  // Determine whether or not this element has form control children. If so, wrap them in a fieldset and use legend instead of label
+  $has_element_children = false;
+  foreach (array_keys($element) as $key) {
+    if (substr($key, 0, 1) !== '#') {
+      $has_element_children = true;
+      break;
+    }
+  }
+
+  if ($has_element_children) {
+    $output .= '<fieldset class="fieldset-invisible">';
+  }
+
   switch ($element['#title_display']) {
     case 'before':
     case 'invisible':
-      $output .= ' ' . theme('form_element_label', $variables);
-      $output .= ' ' . $prefix . $element['#children'] . $suffix . "\n";
+    case 'after':
+      if ($has_element_children) {
+        $title = '<legend>' . $element['#title'] . '</legend>';
+      }
+      else {
+        $title = ' ' . theme('form_element_label', $variables);
+      }
       break;
+  }
 
+  switch ($element['#title_display']) {
+    case 'before':
+    case 'invisible':
+      $output .= $title . $children;
+      break;
+
     case 'after':
-      $output .= ' ' . $prefix . $element['#children'] . $suffix;
-      $output .= ' ' . theme('form_element_label', $variables) . "\n";
+      $output .= $children . $title;
       break;
 
     case 'none':
     case 'attribute':
       // Output no label and no required marker, only the children.
-      $output .= ' ' . $prefix . $element['#children'] . $suffix . "\n";
+      $output .= $children;
       break;
   }
+  $output .= "\n";
 
   if (!empty($element['#description'])) {
     $output .= ' <div class="description">' . $element['#description'] . "</div>\n";
   }
 
+  if ($has_element_children) {
+    $output .= '</fieldset>';
+  }
+
   $output .= "</div>\n";
 
   return $output;
Index: css/webform.css
===================================================================
--- css/webform.css	(revision 1359)
+++ css/webform.css	(working copy)
@@ -11,3 +11,10 @@
 .webform-container-inline div.form-item {
   display: inline;
 }
+
+fieldset.fieldset-invisible {
+  margin: 0;
+  padding: 0;
+  border: none;
+  background-color: inherit;
+}
