diff --git a/Tests/LibWeb/Layout/expected/input-image.txt b/Tests/LibWeb/Layout/expected/input-image.txt
index 74263a5254..9f06c1d7f3 100644
--- a/Tests/LibWeb/Layout/expected/input-image.txt
+++ b/Tests/LibWeb/Layout/expected/input-image.txt
@@ -1,17 +1,31 @@
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 784x120 children: not-inline
- BlockContainer
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp
index d623b19626..597caec823 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp
+++ b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp
@@ -26,6 +26,7 @@
#include
#include
#include
+#include
#include
#include
#include
@@ -1311,6 +1312,24 @@ i32 HTMLInputElement::default_tab_index_value() const
return 0;
}
+// https://html.spec.whatwg.org/multipage/input.html#image-button-state-(type=image):the-input-element-11
+void HTMLInputElement::apply_presentational_hints(CSS::StyleProperties& style) const
+{
+ // The input element supports dimension attributes.
+ if (type_state() != TypeAttributeState::ImageButton)
+ return;
+
+ for_each_attribute([&](auto& name, auto& value) {
+ if (name == HTML::AttributeNames::width) {
+ if (auto parsed_value = parse_dimension_value(value))
+ style.set_property(CSS::PropertyID::Width, parsed_value.release_nonnull());
+ } else if (name == HTML::AttributeNames::height) {
+ if (auto parsed_value = parse_dimension_value(value))
+ style.set_property(CSS::PropertyID::Height, parsed_value.release_nonnull());
+ }
+ });
+}
+
// https://html.spec.whatwg.org/multipage/input.html#the-size-attribute
unsigned HTMLInputElement::size() const
{
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h
index 4fa885efdf..d7b60fb8aa 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h
+++ b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h
@@ -194,6 +194,7 @@ private:
// ^DOM::Element
virtual i32 default_tab_index_value() const override;
+ virtual void apply_presentational_hints(CSS::StyleProperties&) const override;
// ^Layout::ImageProvider
virtual bool is_image_available() const override;