diff --git a/Tests/LibWeb/Layout/expected/block-and-inline/out-of-flows-not-inserted-into-generated-box.txt b/Tests/LibWeb/Layout/expected/block-and-inline/out-of-flows-not-inserted-into-generated-box.txt
new file mode 100644
index 0000000000..565b9f66b4
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/block-and-inline/out-of-flows-not-inserted-into-generated-box.txt
@@ -0,0 +1,19 @@
+Viewport <#document> at (0,0) content-size 800x600 children: not-inline
+ BlockContainer at (0,0) content-size 800x42 [BFC] children: not-inline
+ BlockContainer
at (8,8) content-size 784x17 children: not-inline
+ BlockContainer <(anonymous)> at (8,8) content-size 784x17 children: inline
+ frag 0 from TextNode start: 0, length: 3, rect: [8,8 27.15625x17] baseline: 13.296875
+ "foo"
+ TextNode <#text>
+ BlockContainer at (8,25) content-size 27.640625x17 floating [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 3, rect: [8,25 27.640625x17] baseline: 13.296875
+ "bar"
+ TextNode <#text>
+
+ViewportPaintable (Viewport<#document>) [0,0 800x600]
+ PaintableWithLines (BlockContainer) [0,0 800x42]
+ PaintableWithLines (BlockContainer) [8,8 784x17] overflow: [8,8 784x34]
+ PaintableWithLines (BlockContainer(anonymous)) [8,8 784x17]
+ TextPaintable (TextNode<#text>)
+ PaintableWithLines (BlockContainer
) [8,25 27.640625x17]
+ TextPaintable (TextNode<#text>)
diff --git a/Tests/LibWeb/Layout/input/block-and-inline/out-of-flows-not-inserted-into-generated-box.html b/Tests/LibWeb/Layout/input/block-and-inline/out-of-flows-not-inserted-into-generated-box.html
new file mode 100644
index 0000000000..ac7f1506bd
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/block-and-inline/out-of-flows-not-inserted-into-generated-box.html
@@ -0,0 +1,9 @@
+
bar
diff --git a/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp b/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp
index 71633c24ec..5d8126f6e9 100644
--- a/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp
+++ b/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp
@@ -99,6 +99,7 @@ static Layout::Node& insertion_parent_for_block_node(Layout::NodeWithStyle& layo
if (layout_node.is_out_of_flow()
&& !layout_parent.display().is_flex_inside()
&& !layout_parent.display().is_grid_inside()
+ && !layout_parent.last_child()->is_generated()
&& layout_parent.last_child()->is_anonymous()
&& layout_parent.last_child()->children_are_inline()) {
// Block is out-of-flow & previous sibling was wrapped in an anonymous block.