diff --git a/Libraries/LibWeb/Parser/HTMLDocumentParser.cpp b/Libraries/LibWeb/Parser/HTMLDocumentParser.cpp
index 0d8828fbf33..01ed321995c 100644
--- a/Libraries/LibWeb/Parser/HTMLDocumentParser.cpp
+++ b/Libraries/LibWeb/Parser/HTMLDocumentParser.cpp
@@ -1076,7 +1076,7 @@ void HTMLDocumentParser::handle_in_body(HTMLToken& token)
if (!m_stack_of_open_elements.contains(HTML::TagNames::template_)) {
auto node = m_form_element;
m_form_element = nullptr;
- if (!node || m_stack_of_open_elements.has_in_scope(*node)) {
+ if (!node || !m_stack_of_open_elements.has_in_scope(*node)) {
PARSE_ERROR();
return;
}