diff --git a/inc/html.php b/inc/html.php
index 9fa121db9c95cf2a0dcd40109118dceead690ef7..d370d48b2a99663942d7a4e57ce75e9179031dfa 100644
--- a/inc/html.php
+++ b/inc/html.php
@@ -91,7 +91,7 @@ function html_denied() {
 function html_secedit($text,$show=true){
     global $INFO;
 
-    $regexp = '#<!-- EDIT(\d+) ([A-Z_]+) (?:"([^"]*)" )(?:"([^"]*)" )?\[(\d+-\d*)\] -->#';
+    $regexp = '#<!-- EDIT(?<secid>\d+) (?<target>[A-Z_]+) (?:"(?<name>[^"]*)" )?(?:"(?<hid>[^"]*)" )?\[(?<range>\d+-\d*)\] -->#';
 
     if(!$INFO['writable'] || !$show || $INFO['rev']){
         return preg_replace($regexp,'',$text);
@@ -112,12 +112,16 @@ function html_secedit($text,$show=true){
  * @triggers HTML_SECEDIT_BUTTON
  */
 function html_secedit_button($matches){
-    $data = array('secid'  => $matches[1],
-                  'target' => strtolower($matches[2]),
-                  'hid' => strtolower($matches[4]),
-                  'range'  => $matches[count($matches) - 1]);
-    if (count($matches) === 6) {
-        $data['name'] = $matches[3];
+    $data = array('secid'  => $matches['secid'],
+        'target' => strtolower($matches['target']),
+        'range'  => $matches['range']);
+
+    if (!empty($matches['hid'])) {
+        $data['hid'] = strtolower($matches['hid']);
+    }
+
+    if (!empty($matches['name'])) {
+        $data['name'] = $matches['name'];
     }
 
     return trigger_event('HTML_SECEDIT_BUTTON', $data,
diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php
index dbac1a9822bd73f9ce0447a8b4f768f6e497450a..042aba111ce81f601e5a1d09a3d33d291252f368 100644
--- a/inc/parser/xhtml.php
+++ b/inc/parser/xhtml.php
@@ -1339,7 +1339,8 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
             $class .= ' ' . $classes;
         }
         if($pos !== null) {
-            $class .= ' '.$this->startSectionEdit($pos, 'table');
+            $hid = $this->_headerToLink($class, true);
+            $class .= ' '.$this->startSectionEdit($pos, 'table', '', $hid);
         }
         $this->doc .= '<div class="'.$class.'"><table class="inline">'.
             DOKU_LF;