diff --git a/Libraries/LibHTML/Layout/LayoutTreeBuilder.cpp b/Libraries/LibHTML/Layout/LayoutTreeBuilder.cpp
index 1b56bb830c..2a3637b6b3 100644
--- a/Libraries/LibHTML/Layout/LayoutTreeBuilder.cpp
+++ b/Libraries/LibHTML/Layout/LayoutTreeBuilder.cpp
@@ -32,14 +32,16 @@ static RefPtr create_layout_tree(Node& node, const StyleProperties*
layout_children.append(layout_child.release_nonnull());
});
- for (auto& layout_child : layout_children)
- if (have_block_children && have_inline_children && !layout_child.is_block()) {
+ for (auto& layout_child : layout_children) {
+ if (have_block_children && have_inline_children && layout_child.is_inline()) {
if (is(layout_child) && to(layout_child).text_for_style(*parent_style) == " ")
continue;
layout_node->inline_wrapper().append_child(layout_child);
} else {
layout_node->append_child(layout_child);
}
+ }
+
return layout_node;
}