Bug 297232

Summary: REGRESSION (Safari 18.5): `@media print` does not work when nested
Product: WebKit Reporter: Jordan Pittman <jordan>
Component: CSSAssignee: Matthieu Dubet <m_dubet>
Status: RESOLVED FIXED    
Severity: Normal CC: koivisto, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: Safari 18   
Hardware: All   
OS: All   
Attachments:
Description Flags
Example document demonstrating the bug none

Jordan Pittman
Reported 2025-08-11 12:24:14 PDT
Created attachment 476359 [details] Example document demonstrating the bug If you print a page with the following in Safari you'll see that the div is still visible: ```html <style> .hidden { @media print { display: none; } } </style> <div class="hidden">FAIL if visible on print</div> ``` This is *not* the case if the media query wraps the rules as this works: ```html <style> .hidden { @media print { display: none; } } </style> <div class="hidden">FAIL if visible on print</div> ``` I haven't yet found a workaround that allows nesting to work here in Safari. Tested on: - macOS 15, macOS 26, iOS 18, iOS 26 - Safari 17.3–18.4 (works) - Safari 18.5–18.6 (broken) - Safari 26 and TP (broken) - Webkit Nightly (broken) - Firefox (works) - Chrome (works)
Attachments
Example document demonstrating the bug (390 bytes, text/html)
2025-08-11 12:24 PDT, Jordan Pittman
no flags
Jordan Pittman
Comment 1 2025-08-11 12:31:41 PDT
I meant to put the nightly/build archive version I tested which was the latest as of this bug report: 298509@main
Jordan Pittman
Comment 2 2025-08-11 14:28:26 PDT
Whoops I typo'd the second one. The example file is correct though. Was supposed to be this: ```html <style> @media print { .hidden { display: none; } } </style> <div class="hidden">FAIL if visible on print</div> ```
Alexey Proskuryakov
Comment 3 2025-08-11 16:28:38 PDT
Thank you for such detailed regression information, and the minimized test case!
Radar WebKit Bug Importer
Comment 4 2025-08-11 16:28:49 PDT
Matthieu Dubet
Comment 5 2025-08-14 06:09:54 PDT
EWS
Comment 6 2025-08-18 10:31:50 PDT
Committed 298843@main (e001647e607b): <https://commits.webkit.org/298843@main> Reviewed commits have been landed. Closing PR #49387 and removing active labels.
Note You need to log in before you can comment on or make changes to this bug.