diff --git a/src/document/html/renderer.c b/src/document/html/renderer.c
index f3bdcdd8..01a30553 100644
--- a/src/document/html/renderer.c
+++ b/src/document/html/renderer.c
@@ -1597,8 +1597,8 @@ check_html_form_hierarchy(struct part *part)
foreachsafe (fc, next, form_controls) {
foreach (form, document->forms) {
- if (fc->position < form->form_num
- || form->form_end < fc->position)
+ if (form->form_num <= fc->position
+ && fc->position <= form->form_end)
continue;
fc->form = form;