diff --git a/Tests/LibWeb/Layout/expected/input-element-with-display-inline.txt b/Tests/LibWeb/Layout/expected/input-element-with-display-inline.txt
new file mode 100644
index 0000000000..64f9d6b032
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/input-element-with-display-inline.txt
@@ -0,0 +1,9 @@
+Viewport <#document> at (0,0) content-size 800x600 children: not-inline
+ BlockContainer at (1,1) content-size 798x45.835937 children: not-inline
+ BlockContainer
at (10,10) content-size 780x27.835937 children: inline
+ line 0 width: 202, height: 27.835937, bottom: 27.835937, baseline: 25.835937
+ frag 0 from BlockContainer start: 0, length: 0, rect: [11,11 200x25.835937]
+ BlockContainer at (11,11) content-size 200x25.835937 inline-block children: not-inline
+ BlockContainer <#shadow-root> at (11,11) content-size 0x0 children: not-inline
+ BlockContainer at (14,13) content-size 194x21.835937 children: inline
+ TextNode <#text>
diff --git a/Tests/LibWeb/Layout/input/input-element-with-display-inline.html b/Tests/LibWeb/Layout/input/input-element-with-display-inline.html
new file mode 100644
index 0000000000..f7e8ae1d9c
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/input-element-with-display-inline.html
@@ -0,0 +1,10 @@
+
\ No newline at end of file
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp
index 1cbb2757b6..bd5a85474b 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp
+++ b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp
@@ -71,7 +71,12 @@ JS::GCPtr HTMLInputElement::create_layout_node(NonnullRefPtr(document(), *this, move(style));
- return heap().allocate_without_realm(document(), this, move(style));
+ // AD-HOC: We rewrite `display: inline` to `display: inline-block`.
+ // This is required for the internal shadow tree to work correctly in layout.
+ if (style->display().is_inline_outside() && style->display().is_flow_inside())
+ style->set_property(CSS::PropertyID::Display, CSS::IdentifierStyleValue::create(CSS::ValueID::InlineBlock));
+
+ return Element::create_layout_node_for_display_type(document(), style->display(), style, this);
}
void HTMLInputElement::set_checked(bool checked, ChangeSource change_source)