diff --git a/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp b/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp index e4c7ceb04b..c0deb7af22 100644 --- a/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp +++ b/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp @@ -83,13 +83,15 @@ static Layout::Node& insertion_parent_for_block_node(Layout::NodeWithStyle& layo return layout_parent; } - if (!layout_parent.children_are_inline()) { - // Parent block has block-level children, insert this block into parent. - return layout_parent; - } - if (layout_node.is_floating() || layout_node.is_absolutely_positioned()) { // Block is out-of-flow, it can have inline siblings if necessary. + if (layout_parent.last_child()->children_are_inline()) { + return *layout_parent.last_child(); + } + } + + if (!layout_parent.children_are_inline()) { + // Parent block has block-level children, insert this block into parent. return layout_parent; }