Bug 271040 - Styled container query does not work on body tag
Summary: Styled container query does not work on body tag
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: Safari Technology Preview
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: BrowserCompat, InRadar
Depends on:
Blocks:
 
Reported: 2024-03-15 00:51 PDT by Rogier de Ruijter
Modified: 2024-03-20 10:26 PDT (History)
3 users (show)

See Also:


Attachments
rendering in safari, firefox, chrome (151.92 KB, image/png)
2024-03-17 20:23 PDT, Karl Dubost
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Rogier de Ruijter 2024-03-15 00:51:53 PDT
When using a style container query on a body tag the styles don't get applied. This does work in Chrome.

Reproduction:

```
<!doctype html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>Webkit bugs: styled container queries</title>
  </head>

  <body>
    <style>
      html {
        height: 100vh;
        --dark-mode: true;
      }

      @container style(--dark-mode: true) {
        body {
          background-color: black;
        }
      }
    </style>
  </body>
</html>
```

Another reproduction is here: https://tegenlicht-frontend.vpro-prod.apps.vpro.cluster.chp4.io/programmas/tegenlicht/site/link-in-bio
Comment 1 Karl Dubost 2024-03-17 20:23:10 PDT
Created attachment 470412 [details]
rendering in safari, firefox, chrome

This is showing black only in chrome at the moment.
Comment 2 Radar WebKit Bug Importer 2024-03-17 20:23:35 PDT
<rdar://problem/124875999>
Comment 3 Rogier de Ruijter 2024-03-20 10:26:21 PDT
(In reply to Karl Dubost from comment #1)
> Created attachment 470412 [details]
> rendering in safari, firefox, chrome
> 
> This is showing black only in chrome at the moment.

Yes that is right. I believe Firefox doesn't support styled container queries yet, so it is expected that it shows a white screen there.