diff --git a/Tests/LibWeb/Ref/non-positioned-stacking-context-with-z-index-0.html b/Tests/LibWeb/Ref/non-positioned-stacking-context-with-z-index-0.html
new file mode 100644
index 00000000000..ebbd9b040eb
--- /dev/null
+++ b/Tests/LibWeb/Ref/non-positioned-stacking-context-with-z-index-0.html
@@ -0,0 +1,7 @@
+
+
+
Hello
diff --git a/Tests/LibWeb/Ref/reference/non-positioned-stacking-context-with-z-index-0-ref.html b/Tests/LibWeb/Ref/reference/non-positioned-stacking-context-with-z-index-0-ref.html
new file mode 100644
index 00000000000..0880cf296c1
--- /dev/null
+++ b/Tests/LibWeb/Ref/reference/non-positioned-stacking-context-with-z-index-0-ref.html
@@ -0,0 +1,5 @@
+
+
Hello
diff --git a/Userland/Libraries/LibWeb/Painting/StackingContext.cpp b/Userland/Libraries/LibWeb/Painting/StackingContext.cpp
index 6e09d50d292..5751d25ac10 100644
--- a/Userland/Libraries/LibWeb/Painting/StackingContext.cpp
+++ b/Userland/Libraries/LibWeb/Painting/StackingContext.cpp
@@ -107,7 +107,7 @@ void StackingContext::paint_descendants(PaintContext& context, Paintable const&
return;
}
- if (stacking_context && z_index.has_value())
+ if (stacking_context && z_index.value_or(0) != 0)
return;
if (child.is_positioned() && !z_index.has_value())
return;