Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test has a WPT meta file that expects 1 subtest issues.
- This WPT test may be referenced by the following Test IDs:
- /css/css-conditional/container-queries/style-query-registered-custom-rem-change.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<title>CSS Container Queries Test: style() query with rem unit for registered custom property</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="support/cq-testcommon.js"></script>
<style>
@property --length {
syntax: "<length>";
initial-value: 0px;
inherits: false;
}
:root, body { font-size: 16px; }
#container { --length: 100px; }
#target { color: red; }
@container style(--length: calc(1rem * 10)) {
#target { color: green; }
}
</style>
<div id="container">
<div id="target">Should be green</div>
</div>
<script>
test(() => {
assert_equals(getComputedStyle(target).color, "rgb(255, 0, 0)");
}, "Initially, 1rem * 10 evaluates to 160px");
test(() => {
document.documentElement.style.fontSize = "10px";
assert_equals(getComputedStyle(target).color, "rgb(0, 128, 0)");
}, "Changing the :root font-size to 10px makes 1rem * 10 evaluate to 100px");
</script>