Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /css/cssom/getComputedStyle-root-variables.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<meta charset="utf-8">
<title>getComputedStyle with CSS variables on :root</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
:root { --test-var: red; }
</style>
<body>
<script>
"use strict";
test(() => {
const computedStyles = window.getComputedStyle(document.body);
assert_equals(computedStyles.getPropertyValue("--test-var"), "red");
}, "getComputedStyle should return CSS variables defined on :root");
</script>