Skip to content

Instantly share code, notes, and snippets.

@bkardell
Created November 6, 2014 15:49
Show Gist options
  • Save bkardell/1c160ff1d40c9cc2c8dc to your computer and use it in GitHub Desktop.
Save bkardell/1c160ff1d40c9cc2c8dc to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>CSS Custom Properties/attributes</title>
<style>
:root {
--x-thinger: one;
}
</style>
</head>
<body>
<div id="two" style="--x-thinger: two">
Very simple example showing what it is like to get the property value and mismatch currently in FF nightly implementation: Those assigned in a stylesheet are trimmed (which is nice) and those inline are not (which kinda sucks but might actually be proper as it's just tokens)... Either way they should match.
</div>
<script>
console.log("computed style of documentElement: '%s'", window.getComputedStyle(document.documentElement).getPropertyValue("--x-thinger"));
console.log("computed style of #foo: '%s'", window.getComputedStyle(document.querySelector("#two")).getPropertyValue("--x-thinger"));
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment