diff --git a/lib/scripts/page.js b/lib/scripts/page.js
index 5ac81f33b1fb7d229e343ca87b53952b23eaa9a3..b8e83cb0cd01c09d679b1fd4ab1d58b0f0ec7965 100644
--- a/lib/scripts/page.js
+++ b/lib/scripts/page.js
@@ -27,9 +27,14 @@ dw_page = {
                 // Walk the DOM tree up (first previous siblings, then parents)
                 // until boundary element
                 while($tgt.length > 0 && !$tgt.hasClass('sectionedit' + nr)) {
-                    // $.last gives the DOM-ordered last element:
-                    // prev if present, else parent.
-                    $tgt = $tgt.prev().add($tgt.parent()).last();
+                    // go down when the sectionedit begin marker is below $tgt
+                    if ($tgt.find('.sectionedit' + nr).length > 0) {
+                        $tgt = $tgt.children().last();
+                    } else {
+                        // $.last gives the DOM-ordered last element:
+                        // prev if present, else parent.
+                        $tgt = $tgt.prev().add($tgt.parent()).last();
+                    }
                     $tgt.addClass('section_highlight');
                 }
             })