[csswg-drafts] [css-overflow] Viewport's `overflow` isn't propagated "from the first such child" `<body>` (#12644)

Loirooriol has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-overflow] Viewport's `overflow` isn't propagated "from the first such child" `<body>` ==
https://drafts.csswg.org/css-overflow-3/#overflow-propagation

> UAs must apply the `overflow-*` values set on the root element to the [viewport](https://w3c.github.io/epub-specs/epub33/core/#dfn-viewport) when the root element’s [`display`](https://drafts.csswg.org/css-display-3/#propdef-display) value is not [`none`](https://drafts.csswg.org/css-display-4/#valdef-display-none). However, when the root element is an [[HTML]](https://drafts.csswg.org/css-overflow-3/#biblio-html) [`<html>`](https://html.spec.whatwg.org/multipage/semantics.html#the-html-element) element (including [XML syntax for HTML](https://html.spec.whatwg.org/multipage/introduction.html#html-vs-xhtml)) whose [`overflow`](https://drafts.csswg.org/css-overflow-3/#propdef-overflow) value is [`visible`](https://drafts.csswg.org/css-overflow-3/#valdef-overflow-visible) (in both axes), and that element has as a child a [`<body>`](https://html.spec.whatwg.org/multipage/sections.html#the-body-element) element whose `display` value is also not `none`, user agents must instead apply the `overflow-*` values of the first such child element to the viewport.

```html
<!DOCTYPE html>
<html style="border: solid; height: 200vh; margin: 1em">
<body style="overflow: hidden">
<script>
document.body.after(document.body.cloneNode());
document.body.style.display = "none";
</script>
```

This produces a DOM like

<img width="952" height="190" src="https://github.com/user-attachments/assets/d59e4299-f01f-409c-be73-75bde932ed1c" />

The spec implies that we should skip the first `<body>` (since it has `display: none`) and then propagate `overflow: hidden` from the 2nd `<body>`.

However, all Blink, WebKit and Gecko agree: the viewport gets scrollbars. Only the 1st `<body>` child is capable of propagating its `overflow`.

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/12644 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Friday, 22 August 2025 21:32:58 UTC