diff --git a/Tests/LibWeb/Layout/expected/flex/br-element-does-not-get-blockified-by-itself.txt b/Tests/LibWeb/Layout/expected/flex/br-element-does-not-get-blockified-by-itself.txt
new file mode 100644
index 0000000000..dad4aa2403
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/flex/br-element-does-not-get-blockified-by-itself.txt
@@ -0,0 +1,28 @@
+Viewport <#document> at (0,0) content-size 800x600 children: not-inline
+ BlockContainer at (0,0) content-size 800x600 [BFC] children: not-inline
+ BlockContainer
at (8,8) content-size 784x53.34375 children: not-inline
+ Box at (8,8) content-size 784x53.34375 flex-container(row) [FFC] children: not-inline
+ BlockContainer <(anonymous)> at (8,8) content-size 55.359375x53.34375 flex-item [BFC] children: inline
+ line 0 width: 28.40625, height: 17.46875, bottom: 17.46875, baseline: 13.53125
+ frag 0 from TextNode start: 1, length: 4, rect: [8,8 28.40625x17.46875]
+ "well"
+ line 1 width: 36.84375, height: 17.9375, bottom: 35.40625, baseline: 13.53125
+ frag 0 from TextNode start: 1, length: 5, rect: [8,25 36.84375x17.46875]
+ "hello"
+ line 2 width: 55.359375, height: 18.40625, bottom: 53.34375, baseline: 13.53125
+ frag 0 from TextNode start: 1, length: 7, rect: [8,42 55.359375x17.46875]
+ "friends"
+ TextNode <#text>
+ BreakNode
+ TextNode <#text>
+ BreakNode
+ TextNode <#text>
+
+ViewportPaintable (Viewport<#document>) [0,0 800x600]
+ PaintableWithLines (BlockContainer) [0,0 800x600]
+ PaintableWithLines (BlockContainer) [8,8 784x53.34375]
+ PaintableBox (Box
) [8,8 784x53.34375]
+ PaintableWithLines (BlockContainer(anonymous)) [8,8 55.359375x53.34375]
+ TextPaintable (TextNode<#text>)
+ TextPaintable (TextNode<#text>)
+ TextPaintable (TextNode<#text>)
diff --git a/Tests/LibWeb/Layout/input/flex/br-element-does-not-get-blockified-by-itself.html b/Tests/LibWeb/Layout/input/flex/br-element-does-not-get-blockified-by-itself.html
new file mode 100644
index 0000000000..139907ca3e
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/flex/br-element-does-not-get-blockified-by-itself.html
@@ -0,0 +1,8 @@
+
+
+well
+hello
+friends
diff --git a/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp b/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp
index 1581e7d75b..883b62add3 100644
--- a/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp
+++ b/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp
@@ -69,6 +69,8 @@ static Layout::Node& insertion_parent_for_inline_node(Layout::NodeWithStyle& lay
return layout_parent;
if (layout_parent.display().is_flex_inside() || layout_parent.display().is_grid_inside()) {
+ if (layout_parent.last_child() && layout_parent.last_child()->is_anonymous() && layout_parent.last_child()->children_are_inline())
+ return *layout_parent.last_child();
layout_parent.append_child(layout_parent.create_anonymous_wrapper());
return *layout_parent.last_child();
}