CINXE.COM
CSS Custom Properties for Cascading Variables Module Level 1
<!doctype html><html lang="en"> <head> <meta content="text/html; charset=utf-8" http-equiv="Content-Type"> <meta content="width=device-width, initial-scale=1, shrink-to-fit=no" name="viewport"> <title>CSS Custom Properties for Cascading Variables Module Level 1</title> <meta content="ED" name="w3c-status"> <link href="https://www.w3.org/StyleSheets/TR/2021/W3C-ED" rel="stylesheet"> <meta content="Bikeshed version 60c422380, updated Thu Feb 20 19:11:22 2025 -0800" name="generator"> <link href="https://www.w3.org/TR/css-variables-1/" rel="canonical"> <link href="https://drafts.csswg.org/csslogo.ico" rel="icon"> <meta content="3b4ef61d56f2bcec3045e1371561b362616fd15d" name="revision"> <meta content="dark light" name="color-scheme"> <link href="https://www.w3.org/StyleSheets/TR/2021/dark.css" media="(prefers-color-scheme: dark)" rel="stylesheet" type="text/css"> <style>/* Boilerplate: style-autolinks */ .css.css, .property.property, .descriptor.descriptor { color: var(--a-normal-text); font-size: inherit; font-family: inherit; } .css::before, .property::before, .descriptor::before { content: "‘"; } .css::after, .property::after, .descriptor::after { content: "’"; } .property, .descriptor { /* Don't wrap property and descriptor names */ white-space: nowrap; } .type { /* CSS value <type> */ font-style: italic; } pre .property::before, pre .property::after { content: ""; } [data-link-type="property"]::before, [data-link-type="propdesc"]::before, [data-link-type="descriptor"]::before, [data-link-type="value"]::before, [data-link-type="function"]::before, [data-link-type="at-rule"]::before, [data-link-type="selector"]::before, [data-link-type="maybe"]::before { content: "‘"; } [data-link-type="property"]::after, [data-link-type="propdesc"]::after, [data-link-type="descriptor"]::after, [data-link-type="value"]::after, [data-link-type="function"]::after, [data-link-type="at-rule"]::after, [data-link-type="selector"]::after, [data-link-type="maybe"]::after { content: "’"; } [data-link-type].production::before, [data-link-type].production::after, .prod [data-link-type]::before, .prod [data-link-type]::after { content: ""; } [data-link-type=element], [data-link-type=element-attr] { font-family: Menlo, Consolas, "DejaVu Sans Mono", monospace; font-size: .9em; } [data-link-type=element]::before { content: "<" } [data-link-type=element]::after { content: ">" } [data-link-type=biblio] { white-space: pre; } @media (prefers-color-scheme: dark) { :root { --selflink-text: black; --selflink-bg: silver; --selflink-hover-text: white; } } </style> <style>/* Boilerplate: style-colors */ /* Any --*-text not paired with a --*-bg is assumed to have a transparent bg */ :root { color-scheme: light dark; --text: black; --bg: white; --unofficial-watermark: url(https://www.w3.org/StyleSheets/TR/2016/logos/UD-watermark); --logo-bg: #1a5e9a; --logo-active-bg: #c00; --logo-text: white; --tocnav-normal-text: #707070; --tocnav-normal-bg: var(--bg); --tocnav-hover-text: var(--tocnav-normal-text); --tocnav-hover-bg: #f8f8f8; --tocnav-active-text: #c00; --tocnav-active-bg: var(--tocnav-normal-bg); --tocsidebar-text: var(--text); --tocsidebar-bg: #f7f8f9; --tocsidebar-shadow: rgba(0,0,0,.1); --tocsidebar-heading-text: hsla(203,20%,40%,.7); --toclink-text: var(--text); --toclink-underline: #3980b5; --toclink-visited-text: var(--toclink-text); --toclink-visited-underline: #054572; --heading-text: #005a9c; --hr-text: var(--text); --algo-border: #def; --del-text: red; --del-bg: transparent; --ins-text: #080; --ins-bg: transparent; --a-normal-text: #034575; --a-normal-underline: #bbb; --a-visited-text: var(--a-normal-text); --a-visited-underline: #707070; --a-hover-bg: rgba(75%, 75%, 75%, .25); --a-active-text: #c00; --a-active-underline: #c00; --blockquote-border: silver; --blockquote-bg: transparent; --blockquote-text: currentcolor; --issue-border: #e05252; --issue-bg: #fbe9e9; --issue-text: var(--text); --issueheading-text: #831616; --example-border: #e0cb52; --example-bg: #fcfaee; --example-text: var(--text); --exampleheading-text: #574b0f; --note-border: #52e052; --note-bg: #e9fbe9; --note-text: var(--text); --noteheading-text: hsl(120, 70%, 30%); --notesummary-underline: silver; --assertion-border: #aaa; --assertion-bg: #eee; --assertion-text: black; --advisement-border: orange; --advisement-bg: #fec; --advisement-text: var(--text); --advisementheading-text: #b35f00; --warning-border: red; --warning-bg: hsla(40,100%,50%,0.95); --warning-text: var(--text); --amendment-border: #330099; --amendment-bg: #F5F0FF; --amendment-text: var(--text); --amendmentheading-text: #220066; --def-border: #8ccbf2; --def-bg: #def; --def-text: var(--text); --defrow-border: #bbd7e9; --datacell-border: silver; --indexinfo-text: #707070; --indextable-hover-text: black; --indextable-hover-bg: #f7f8f9; --outdatedspec-bg: rgba(0, 0, 0, .5); --outdatedspec-text: black; --outdated-bg: maroon; --outdated-text: white; --outdated-shadow: red; --editedrec-bg: darkorange; } @media (prefers-color-scheme: dark) { :root { --text: #ddd; --bg: black; --unofficial-watermark: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='400' height='400'%3E%3Cg fill='%23100808' transform='translate(200 200) rotate(-45) translate(-200 -200)' stroke='%23100808' stroke-width='3'%3E%3Ctext x='50%25' y='220' style='font: bold 70px sans-serif; text-anchor: middle; letter-spacing: 6px;'%3EUNOFFICIAL%3C/text%3E%3Ctext x='50%25' y='305' style='font: bold 70px sans-serif; text-anchor: middle; letter-spacing: 6px;'%3EDRAFT%3C/text%3E%3C/g%3E%3C/svg%3E"); --logo-bg: #1a5e9a; --logo-active-bg: #c00; --logo-text: white; --tocnav-normal-text: #999; --tocnav-normal-bg: var(--bg); --tocnav-hover-text: var(--tocnav-normal-text); --tocnav-hover-bg: #080808; --tocnav-active-text: #f44; --tocnav-active-bg: var(--tocnav-normal-bg); --tocsidebar-text: var(--text); --tocsidebar-bg: #080808; --tocsidebar-shadow: rgba(255,255,255,.1); --tocsidebar-heading-text: hsla(203,20%,40%,.7); --toclink-text: var(--text); --toclink-underline: #6af; --toclink-visited-text: var(--toclink-text); --toclink-visited-underline: #054572; --heading-text: #8af; --hr-text: var(--text); --algo-border: #456; --del-text: #f44; --del-bg: transparent; --ins-text: #4a4; --ins-bg: transparent; --a-normal-text: #6af; --a-normal-underline: #555; --a-visited-text: var(--a-normal-text); --a-visited-underline: var(--a-normal-underline); --a-hover-bg: rgba(25%, 25%, 25%, .2); --a-active-text: #f44; --a-active-underline: var(--a-active-text); --borderedblock-bg: rgba(255, 255, 255, .05); --blockquote-border: silver; --blockquote-bg: var(--borderedblock-bg); --blockquote-text: currentcolor; --issue-border: #e05252; --issue-bg: var(--borderedblock-bg); --issue-text: var(--text); --issueheading-text: hsl(0deg, 70%, 70%); --example-border: hsl(50deg, 90%, 60%); --example-bg: var(--borderedblock-bg); --example-text: var(--text); --exampleheading-text: hsl(50deg, 70%, 70%); --note-border: hsl(120deg, 100%, 35%); --note-bg: var(--borderedblock-bg); --note-text: var(--text); --noteheading-text: hsl(120, 70%, 70%); --notesummary-underline: silver; --assertion-border: #444; --assertion-bg: var(--borderedblock-bg); --assertion-text: var(--text); --advisement-border: orange; --advisement-bg: #222218; --advisement-text: var(--text); --advisementheading-text: #f84; --warning-border: red; --warning-bg: hsla(40,100%,20%,0.95); --warning-text: var(--text); --amendment-border: #330099; --amendment-bg: #080010; --amendment-text: var(--text); --amendmentheading-text: #cc00ff; --def-border: #8ccbf2; --def-bg: #080818; --def-text: var(--text); --defrow-border: #136; --datacell-border: silver; --indexinfo-text: #aaa; --indextable-hover-text: var(--text); --indextable-hover-bg: #181818; --outdatedspec-bg: rgba(255, 255, 255, .5); --outdatedspec-text: black; --outdated-bg: maroon; --outdated-text: white; --outdated-shadow: red; --editedrec-bg: darkorange; } /* In case a transparent-bg image doesn't expect to be on a dark bg, which is quite common in practice... */ img { background: white; } } </style> <style>/* Boilerplate: style-counters */ body { counter-reset: example figure issue; } .issue { counter-increment: issue; } .issue:not(.no-marker)::before { content: "Issue " counter(issue); } .example { counter-increment: example; } .example:not(.no-marker)::before { content: "Example " counter(example); } .invalid.example:not(.no-marker)::before, .illegal.example:not(.no-marker)::before { content: "Invalid Example" counter(example); } figcaption { counter-increment: figure; } figcaption:not(.no-marker)::before { content: "Figure " counter(figure) " "; } </style> <style>/* Boilerplate: style-dfn-panel */ :root { --dfnpanel-bg: #ddd; --dfnpanel-text: var(--text); --dfnpanel-target-bg: #ffc; --dfnpanel-target-outline: orange; } @media (prefers-color-scheme: dark) { :root { --dfnpanel-bg: #222; --dfnpanel-text: var(--text); --dfnpanel-target-bg: #333; --dfnpanel-target-outline: silver; } } .dfn-panel { position: absolute; z-index: 35; width: 20em; width: 300px; height: auto; max-height: 500px; overflow: auto; padding: 0.5em 0.75em; font: small Helvetica Neue, sans-serif, Droid Sans Fallback; background: var(--dfnpanel-bg); color: var(--dfnpanel-text); border: outset 0.2em; white-space: normal; /* in case it's moved into a pre */ } .dfn-panel:not(.on) { display: none; } .dfn-panel * { margin: 0; padding: 0; text-indent: 0; } .dfn-panel > b { display: block; } .dfn-panel a { color: var(--dfnpanel-text); } .dfn-panel a:not(:hover) { text-decoration: none !important; border-bottom: none !important; } .dfn-panel a:focus { outline: 5px auto Highlight; outline: 5px auto -webkit-focus-ring-color; } .dfn-panel > b + b { margin-top: 0.25em; } .dfn-panel ul { padding: 0 0 0 1em; list-style: none; } .dfn-panel li a { max-width: calc(300px - 1.5em - 1em); overflow: hidden; text-overflow: ellipsis; } .dfn-panel.activated { display: inline-block; position: fixed; left: 8px; bottom: 2em; margin: 0 auto; max-width: calc(100vw - 1.5em - .4em - .5em); max-height: 30vh; transition: left 1s ease-out, bottom 1s ease-out; } .dfn-panel .link-item:hover { text-decoration: underline; } .dfn-panel .link-item .copy-icon { opacity: 0; } .dfn-panel .link-item:hover .copy-icon, .dfn-panel .link-item .copy-icon:focus { opacity: 1; } .dfn-panel .copy-icon { display: inline-block; margin-right: 0.5em; width: 0.85em; height: 1em; border-radius: 3px; background-color: #ccc; cursor: pointer; } .dfn-panel .copy-icon .icon { width: 100%; height: 100%; background-color: #fff; display: flex; justify-content: center; align-items: center; position: relative; } .dfn-panel .copy-icon .icon::before { content: ""; position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: 1px solid black; background-color: #ccc; opacity: 0.25; transform: translate(3px, -3px); } .dfn-panel .copy-icon:active .icon::before { opacity: 1; } .dfn-paneled[role="button"] { cursor: help; } .highlighted { animation: target-fade 3s; } @keyframes target-fade { from { background-color: var(--dfnpanel-target-bg); outline: 5px solid var(--dfnpanel-target-outline); } to { color: var(--a-normal-text); background-color: transparent; outline: transparent; } } </style> <style>/* Boilerplate: style-issues */ a[href].issue-return { float: right; float: inline-end; color: var(--issueheading-text); font-weight: bold; text-decoration: none; } </style> <style>/* Boilerplate: style-md-lists */ /* This is a weird hack for me not yet following the commonmark spec regarding paragraph and lists. */ [data-md] > :first-child { margin-top: 0; } [data-md] > :last-child { margin-bottom: 0; } </style> <style>/* Boilerplate: style-mdn-anno */ :root { --mdn-bg: #EEE; --mdn-shadow: #999; --mdn-nosupport-text: #ccc; --mdn-pass: green; --mdn-fail: red; } @media (prefers-color-scheme: dark) { :root { --mdn-bg: #222; --mdn-shadow: #444; --mdn-nosupport-text: #666; --mdn-pass: #690; --mdn-fail: #d22; } } .mdn-anno { background: var(--mdn-bg, #EEE); border-radius: .25em; box-shadow: 0 0 3px var(--mdn-shadow, #999); color: var(--text, black); font: 1em sans-serif; hyphens: none; max-width: min-content; overflow: hidden; padding: 0.2em; position: absolute; right: 0.3em; top: auto; white-space: nowrap; word-wrap: normal; z-index: 8; } .mdn-anno.unpositioned { display: none; } .mdn-anno.overlapping-main { opacity: .2; transition: opacity .1s; } .mdn-anno[open] { opacity: 1; z-index: 9; min-width: 9em; } .mdn-anno:hover { opacity: 1; outline: var(--text, black) 1px solid; } .mdn-anno > summary { font-weight: normal; text-align: right; cursor: pointer; display: block; } .mdn-anno > summary > .less-than-two-engines-flag { color: var(--mdn-fail); padding-right: 2px; } .mdn-anno > summary > .all-engines-flag { color: var(--mdn-pass); padding-right: 2px; } .mdn-anno > summary > span { color: #fff; background-color: #000; font-weight: normal; font-family: zillaslab, Palatino, "Palatino Linotype", serif; padding: 2px 3px 0px 3px; line-height: 1.3em; vertical-align: top; } .mdn-anno > .feature { margin-top: 20px; } .mdn-anno > .feature:not(:first-of-type) { border-top: 1px solid #999; margin-top: 6px; padding-top: 2px; } .mdn-anno > .feature > .less-than-two-engines-text { color: var(--mdn-fail); } .mdn-anno > .feature > .all-engines-text { color: var(--mdn-pass); } .mdn-anno > .feature > p { font-size: .75em; margin-top: 6px; margin-bottom: 0; } .mdn-anno > .feature > p + p { margin-top: 3px; } .mdn-anno > .feature > .support { display: block; font-size: 0.6em; margin: 0; padding: 0; margin-top: 2px; } .mdn-anno > .feature > .support + div { padding-top: 0.5em; } .mdn-anno > .feature > .support > hr { display: block; border: none; border-top: 1px dotted #999; padding: 3px 0px 0px 0px; margin: 2px 3px 0px 3px; } .mdn-anno > .feature > .support > hr::before { content: ""; } .mdn-anno > .feature > .support > span { padding: 0.2em 0; display: block; display: table; } .mdn-anno > .feature > .support > span.no { color: var(--mdn-nosupport-text); filter: grayscale(100%); } .mdn-anno > .feature > .support > span.no::before { opacity: 0.5; } .mdn-anno > .feature > .support > span:first-of-type { padding-top: 0.5em; } .mdn-anno > .feature > .support > span > span { padding: 0 0.5em; display: table-cell; } .mdn-anno > .feature > .support > span > span:first-child { width: 100%; } .mdn-anno > .feature > .support > span > span:last-child { width: 100%; white-space: pre; padding: 0; } .mdn-anno > .feature > .support > span::before { content: ' '; display: table-cell; min-width: 1.5em; height: 1.5em; background: no-repeat center center; background-size: contain; text-align: right; font-size: 0.75em; font-weight: bold; } .mdn-anno > .feature > .support > .chrome_android::before { background-image: url(https://resources.whatwg.org/browser-logos/chrome.svg); } .mdn-anno > .feature > .support > .firefox_android::before { background-image: url(https://resources.whatwg.org/browser-logos/firefox.png); } .mdn-anno > .feature > .support > .chrome::before { background-image: url(https://resources.whatwg.org/browser-logos/chrome.svg); } .mdn-anno > .feature > .support > .edge_blink::before { background-image: url(https://resources.whatwg.org/browser-logos/edge.svg); } .mdn-anno > .feature > .support > .edge::before { background-image: url(https://resources.whatwg.org/browser-logos/edge_legacy.svg); } .mdn-anno > .feature > .support > .firefox::before { background-image: url(https://resources.whatwg.org/browser-logos/firefox.png); } .mdn-anno > .feature > .support > .ie::before { background-image: url(https://resources.whatwg.org/browser-logos/ie.png); } .mdn-anno > .feature > .support > .safari_ios::before { background-image: url(https://resources.whatwg.org/browser-logos/safari-ios.svg); } .mdn-anno > .feature > .support > .nodejs::before { background-image: url(https://nodejs.org/favicon.ico); } .mdn-anno > .feature > .support > .opera_android::before { background-image: url(https://resources.whatwg.org/browser-logos/opera.svg); } .mdn-anno > .feature > .support > .opera::before { background-image: url(https://resources.whatwg.org/browser-logos/opera.svg); } .mdn-anno > .feature > .support > .safari::before { background-image: url(https://resources.whatwg.org/browser-logos/safari.png); } .mdn-anno > .feature > .support > .samsunginternet_android::before { background-image: url(https://resources.whatwg.org/browser-logos/samsung.svg); } .mdn-anno > .feature > .support > .webview_android::before { background-image: url(https://resources.whatwg.org/browser-logos/android-webview.png); } .name-slug-mismatch { color: red; } .caniuse-status:hover { z-index: 9; } /* dt, li, .issue, .note, and .example are "position: relative", so to put annotation at right margin, must move to right of containing block */; .h-entry:not(.status-LS) dt > .mdn-anno, .h-entry:not(.status-LS) li > .mdn-anno, .h-entry:not(.status-LS) .issue > .mdn-anno, .h-entry:not(.status-LS) .note > .mdn-anno, .h-entry:not(.status-LS) .example > .mdn-anno { right: -6.7em; } .h-entry p + .mdn-anno { margin-top: 0; } h2 + .mdn-anno.after { margin: -48px 0 0 0; } h3 + .mdn-anno.after { margin: -46px 0 0 0; } h4 + .mdn-anno.after { margin: -42px 0 0 0; } h5 + .mdn-anno.after { margin: -40px 0 0 0; } h6 + .mdn-anno.after { margin: -40px 0 0 0; } </style> <style>/* Boilerplate: style-ref-hints */ :root { --ref-hint-bg: #ddd; --ref-hint-text: var(--text); } @media (prefers-color-scheme: dark) { :root { --ref-hint-bg: #222; --ref-hint-text: var(--text); } } .ref-hint { display: inline-block; position: absolute; z-index: 35; width: 20em; width: 300px; height: auto; max-height: 500px; overflow: auto; padding: 0.5em 0.5em; font: small Helvetica Neue, sans-serif, Droid Sans Fallback; background: var(--ref-hint-bg); color: var(--ref-hint-text); border: outset 0.2em; white-space: normal; /* in case it's moved into a pre */ } .ref-hint * { margin: 0; padding: 0; text-indent: 0; } .ref-hint ul { padding: 0 0 0 1em; list-style: none; } </style> <style>/* Boilerplate: style-selflinks */ :root { --selflink-text: white; --selflink-bg: gray; --selflink-hover-text: black; } .heading, .issue, .note, .example, li, dt { position: relative; } a.self-link { position: absolute; top: 0; left: calc(-1 * (3.5rem - 26px)); width: calc(3.5rem - 26px); height: 2em; text-align: center; border: none; transition: opacity .2s; opacity: .5; } a.self-link:hover { opacity: 1; } .heading > a.self-link { font-size: 83%; } .example > a.self-link, .note > a.self-link, .issue > a.self-link { /* These blocks are overflow:auto, so positioning outside doesn't work. */ left: auto; right: 0; } li > a.self-link { left: calc(-1 * (3.5rem - 26px) - 2em); } dfn > a.self-link { top: auto; left: auto; opacity: 0; width: 1.5em; height: 1.5em; background: var(--selflink-bg); color: var(--selflink-text); font-style: normal; transition: opacity .2s, background-color .2s, color .2s; } dfn:hover > a.self-link { opacity: 1; } dfn > a.self-link:hover { color: var(--selflink-hover-text); } a.self-link::before { content: "¶"; } .heading > a.self-link::before { content: "§"; } dfn > a.self-link::before { content: "#"; } </style> <style>/* Boilerplate: style-syntax-highlighting */ code.highlight { padding: .1em; border-radius: .3em; } pre.highlight, pre > code.highlight { display: block; padding: 1em; margin: .5em 0; overflow: auto; border-radius: 0; } .highlight:not(.idl) { background: rgba(0, 0, 0, .03); } c-[a] { color: #990055 } /* Keyword.Declaration */ c-[b] { color: #990055 } /* Keyword.Type */ c-[c] { color: #708090 } /* Comment */ c-[d] { color: #708090 } /* Comment.Multiline */ c-[e] { color: #0077aa } /* Name.Attribute */ c-[f] { color: #669900 } /* Name.Tag */ c-[g] { color: #222222 } /* Name.Variable */ c-[k] { color: #990055 } /* Keyword */ c-[l] { color: #000000 } /* Literal */ c-[m] { color: #000000 } /* Literal.Number */ c-[n] { color: #0077aa } /* Name */ c-[o] { color: #999999 } /* Operator */ c-[p] { color: #999999 } /* Punctuation */ c-[s] { color: #a67f59 } /* Literal.String */ c-[t] { color: #a67f59 } /* Literal.String.Single */ c-[u] { color: #a67f59 } /* Literal.String.Double */ c-[cp] { color: #708090 } /* Comment.Preproc */ c-[c1] { color: #708090 } /* Comment.Single */ c-[cs] { color: #708090 } /* Comment.Special */ c-[kc] { color: #990055 } /* Keyword.Constant */ c-[kn] { color: #990055 } /* Keyword.Namespace */ c-[kp] { color: #990055 } /* Keyword.Pseudo */ c-[kr] { color: #990055 } /* Keyword.Reserved */ c-[ld] { color: #000000 } /* Literal.Date */ c-[nc] { color: #0077aa } /* Name.Class */ c-[no] { color: #0077aa } /* Name.Constant */ c-[nd] { color: #0077aa } /* Name.Decorator */ c-[ni] { color: #0077aa } /* Name.Entity */ c-[ne] { color: #0077aa } /* Name.Exception */ c-[nf] { color: #0077aa } /* Name.Function */ c-[nl] { color: #0077aa } /* Name.Label */ c-[nn] { color: #0077aa } /* Name.Namespace */ c-[py] { color: #0077aa } /* Name.Property */ c-[ow] { color: #999999 } /* Operator.Word */ c-[mb] { color: #000000 } /* Literal.Number.Bin */ c-[mf] { color: #000000 } /* Literal.Number.Float */ c-[mh] { color: #000000 } /* Literal.Number.Hex */ c-[mi] { color: #000000 } /* Literal.Number.Integer */ c-[mo] { color: #000000 } /* Literal.Number.Oct */ c-[sb] { color: #a67f59 } /* Literal.String.Backtick */ c-[sc] { color: #a67f59 } /* Literal.String.Char */ c-[sd] { color: #a67f59 } /* Literal.String.Doc */ c-[se] { color: #a67f59 } /* Literal.String.Escape */ c-[sh] { color: #a67f59 } /* Literal.String.Heredoc */ c-[si] { color: #a67f59 } /* Literal.String.Interpol */ c-[sx] { color: #a67f59 } /* Literal.String.Other */ c-[sr] { color: #a67f59 } /* Literal.String.Regex */ c-[ss] { color: #a67f59 } /* Literal.String.Symbol */ c-[vc] { color: #0077aa } /* Name.Variable.Class */ c-[vg] { color: #0077aa } /* Name.Variable.Global */ c-[vi] { color: #0077aa } /* Name.Variable.Instance */ c-[il] { color: #000000 } /* Literal.Number.Integer.Long */ @media (prefers-color-scheme: dark) { .highlight:not(.idl) { background: rgba(255, 255, 255, .05); } c-[a] { color: #d33682 } /* Keyword.Declaration */ c-[b] { color: #d33682 } /* Keyword.Type */ c-[c] { color: #2aa198 } /* Comment */ c-[d] { color: #2aa198 } /* Comment.Multiline */ c-[e] { color: #268bd2 } /* Name.Attribute */ c-[f] { color: #b58900 } /* Name.Tag */ c-[g] { color: #cb4b16 } /* Name.Variable */ c-[k] { color: #d33682 } /* Keyword */ c-[l] { color: #657b83 } /* Literal */ c-[m] { color: #657b83 } /* Literal.Number */ c-[n] { color: #268bd2 } /* Name */ c-[o] { color: #657b83 } /* Operator */ c-[p] { color: #657b83 } /* Punctuation */ c-[s] { color: #6c71c4 } /* Literal.String */ c-[t] { color: #6c71c4 } /* Literal.String.Single */ c-[u] { color: #6c71c4 } /* Literal.String.Double */ c-[ch] { color: #2aa198 } /* Comment.Hashbang */ c-[cp] { color: #2aa198 } /* Comment.Preproc */ c-[cpf] { color: #2aa198 } /* Comment.PreprocFile */ c-[c1] { color: #2aa198 } /* Comment.Single */ c-[cs] { color: #2aa198 } /* Comment.Special */ c-[kc] { color: #d33682 } /* Keyword.Constant */ c-[kn] { color: #d33682 } /* Keyword.Namespace */ c-[kp] { color: #d33682 } /* Keyword.Pseudo */ c-[kr] { color: #d33682 } /* Keyword.Reserved */ c-[ld] { color: #657b83 } /* Literal.Date */ c-[nc] { color: #268bd2 } /* Name.Class */ c-[no] { color: #268bd2 } /* Name.Constant */ c-[nd] { color: #268bd2 } /* Name.Decorator */ c-[ni] { color: #268bd2 } /* Name.Entity */ c-[ne] { color: #268bd2 } /* Name.Exception */ c-[nf] { color: #268bd2 } /* Name.Function */ c-[nl] { color: #268bd2 } /* Name.Label */ c-[nn] { color: #268bd2 } /* Name.Namespace */ c-[py] { color: #268bd2 } /* Name.Property */ c-[ow] { color: #657b83 } /* Operator.Word */ c-[mb] { color: #657b83 } /* Literal.Number.Bin */ c-[mf] { color: #657b83 } /* Literal.Number.Float */ c-[mh] { color: #657b83 } /* Literal.Number.Hex */ c-[mi] { color: #657b83 } /* Literal.Number.Integer */ c-[mo] { color: #657b83 } /* Literal.Number.Oct */ c-[sa] { color: #6c71c4 } /* Literal.String.Affix */ c-[sb] { color: #6c71c4 } /* Literal.String.Backtick */ c-[sc] { color: #6c71c4 } /* Literal.String.Char */ c-[dl] { color: #6c71c4 } /* Literal.String.Delimiter */ c-[sd] { color: #6c71c4 } /* Literal.String.Doc */ c-[se] { color: #6c71c4 } /* Literal.String.Escape */ c-[sh] { color: #6c71c4 } /* Literal.String.Heredoc */ c-[si] { color: #6c71c4 } /* Literal.String.Interpol */ c-[sx] { color: #6c71c4 } /* Literal.String.Other */ c-[sr] { color: #6c71c4 } /* Literal.String.Regex */ c-[ss] { color: #6c71c4 } /* Literal.String.Symbol */ c-[fm] { color: #268bd2 } /* Name.Function.Magic */ c-[vc] { color: #cb4b16 } /* Name.Variable.Class */ c-[vg] { color: #cb4b16 } /* Name.Variable.Global */ c-[vi] { color: #cb4b16 } /* Name.Variable.Instance */ c-[vm] { color: #cb4b16 } /* Name.Variable.Magic */ c-[il] { color: #657b83 } /* Literal.Number.Integer.Long */ } </style> <style>/* Boilerplate: style-var-click-highlighting */ /* Colors were chosen in Lab using https://nixsensor.com/free-color-converter/ D50 2deg illuminant, L in [0,100], a and b in [-128, 128] 0 = lab(85,0,85) 1 = lab(85,80,30) 2 = lab(85,-40,40) 3 = lab(85,-50,0) 4 = lab(85,5,15) 5 = lab(85,-10,-50) 6 = lab(85,35,-15) For darkmode: 0 = oklab(50% 0% 108%) 1 = oklab(50% -51% 51%) 2 = oklab(50% -64% -20%) 3 = oklab(50% 6% 19%) 4 = oklab(50% -12% -64%) 5 = oklab(50% 44% -19%) 6 = oklab(50% 102% 38%) */ [data-algorithm] var { cursor: pointer; } var[data-var-color] { background-color: var(--var-bg); box-shadow: 0 0 0 2px var(--var-bg); } var[data-var-color] { --var-bg: #F4D200; } var[data-var-color="1"] { --var-bg: #FF87A2; } var[data-var-color="2"] { --var-bg: #96E885; } var[data-var-color="3"] { --var-bg: #3EEED2; } var[data-var-color="4"] { --var-bg: #EACFB6; } var[data-var-color="5"] { --var-bg: #82DDFF; } var[data-var-color="6"] { --var-vg: #FFBCF2; } @media (prefers-color-scheme: dark) { var[data-var-color] { --var-bg: #bc1a00; } var[data-var-color="1"] { --var-bg: #007f00; } var[data-var-color="2"] { --var-bg: #008698; } var[data-var-color="3"] { --var-bg: #7f5b2b; } var[data-var-color="4"] { --var-bg: #004df3; } var[data-var-color="5"] { --var-bg: #a1248a; } var[data-var-color="6"] { --var-vg: #ff0000; } } </style> <style>/* Boilerplate: style-wpt */ :root { --wpt-border: hsl(0, 0%, 60%); --wpt-bg: hsl(0, 0%, 95%); --wpt-text: var(--text); --wptheading-text: hsl(0, 0%, 30%); } @media (prefers-color-scheme: dark) { :root { --wpt-border: hsl(0, 0%, 30%); --wpt-bg: var(--borderedblock-bg); --wpt-text: var(--text); --wptheading-text: hsl(0, 0%, 60%); } } .wpt-tests-block { list-style: none; border-left: .5em solid var(--wpt-border); background: var(--wpt-bg); color: var(--wpt-text); margin: 1em auto; padding: .5em; } .wpt-tests-block summary { color: var(--wptheading-text); font-weight: normal; text-transform: uppercase; } .wpt-tests-block summary::marker{ color: var(--wpt-border); } .wpt-tests-block summary:hover::marker{ color: var(--wpt-text); } /* The only content of a wpt test block in its closed state is the <summary>, which contains the word TESTS, and that is absolutely positioned. In that closed state, wpt test blocks are styled to have a top margin whose height is exactly equal to the height of the absolutely positioned <summary>, and no other background/padding/margin/border. The wpt test block elements will therefore allow the maring of the previous/next block elements to collapse through them; if this combined margin would be larger than its own top margin, it stays as is, and therefore the pre-existing vertical rhythm of the document is undisturbed. If that combined margin would be smaller, it is grown to that size. This means that the wpt test block ensures that there's always enough vertical space to insert the summary, without adding more than is needed. */ .wpt-tests-block:not([open]){ padding: 0; border: none; background: none; font-size: 0.75em; line-height: 1; position: relative; margin: 1em 0 0; } .wpt-tests-block:not([open]) summary { position: absolute; right: 0; bottom: 0; } /* It is possible that both the last child of a block element and the block element itself would be annotated with a <wpt> block each. If the block element has a padding or a border, that's fine, but otherwise the bottom margin of the block and of its last child would collapse and both <wpt> elements would overlap, being both placed there. To avoid that, add 1px of padding to the <wpt> element annotating the last child to prevent the bottom margin of the block and of its last child from collapsing (and as much negative margin, as wel only want to prevent margin collapsing, but are not trying to actually take more space). */ .wpt-tests-block:not([open]):last-child { padding-bottom: 1px; margin-bottom: -1px; } /* Exception to the previous rule: don't do that in non-last list items, because it's not necessary, and would therefore consume more space than strictly needed. Lists must have list items as children, not <wpt> elements, so a <wpt> element cannot be a sibling of a list item, and the collision that the previous rule avoids cannot happen. */ li:not(:last-child) > .wpt-tests-block:not([open]):last-child, dd:not(:last-child) > .wpt-tests-block:not([open]):last-child { padding-bottom: 0; margin-bottom: 0; } .wpt-tests-block:not([open]):not(:hover){ opacity: 0.5; } .wpt-tests-list { list-style: none; display: grid; margin: 0; padding: 0; grid-template-columns: 1fr max-content auto auto; grid-column-gap: .5em; } .wpt-tests-block hr:last-child { display: none; } .wpt-test { display: contents; } .wpt-test > a { text-decoration: underline; border: none; } .wpt-test > .wpt-name { grid-column: 1; } .wpt-test > .wpt-results { grid-column: 2; } .wpt-test > .wpt-live { grid-column: 3; } .wpt-test > .wpt-source { grid-column: 4; } .wpt-test > .wpt-results { display: flex; gap: .1em; } .wpt-test .wpt-result { display: inline-block; height: 1em; width: 1em; border-radius: 50%; position: relative; } </style> <body class="h-entry"> <div class="head"> <p data-fill-with="logo"><a class="logo" href="https://www.w3.org/"> <img alt="W3C" height="48" src="https://www.w3.org/StyleSheets/TR/2021/logos/W3C" width="72"> </a> </p> <h1 class="p-name no-ref" id="title">CSS Custom Properties for Cascading Variables Module Level 1</h1> <p id="w3c-state"><a href="https://www.w3.org/standards/types/#ED">Editor’s Draft</a>, <time class="dt-updated" datetime="2025-02-22">22 February 2025</time></p> <details open> <summary>More details about this document</summary> <div data-fill-with="spec-metadata"> <dl> <dt>This version: <dd><a class="u-url" href="https://drafts.csswg.org/css-variables/">https://drafts.csswg.org/css-variables/</a> <dt>Latest published version: <dd><a href="https://www.w3.org/TR/css-variables-1/">https://www.w3.org/TR/css-variables-1/</a> <dt>Previous Versions: <dd><a href="https://www.w3.org/TR/2022/CR-css-variables-1-20220616/" rel="prev">https://www.w3.org/TR/2022/CR-css-variables-1-20220616/</a> <dd><a href="https://www.w3.org/TR/2021/CRD-css-variables-1-20211111/" rel="prev">https://www.w3.org/TR/2021/CRD-css-variables-1-20211111/</a> <dd><a href="https://www.w3.org/TR/2015/CR-css-variables-1-20151203/" rel="prev">https://www.w3.org/TR/2015/CR-css-variables-1-20151203/</a> <dd><a href="https://www.w3.org/TR/2014/WD-css-variables-1-20140506/" rel="prev">https://www.w3.org/TR/2014/WD-css-variables-1-20140506/</a> <dd><a href="https://www.w3.org/TR/2013/WD-css-variables-1-20130620/" rel="prev">https://www.w3.org/TR/2013/WD-css-variables-1-20130620/</a> <dd><a href="https://www.w3.org/TR/2013/WD-css-variables-20130312/" rel="prev">https://www.w3.org/TR/2013/WD-css-variables-20130312/</a> <dd><a href="https://www.w3.org/TR/2012/WD-css-variables-20120410/" rel="prev">https://www.w3.org/TR/2012/WD-css-variables-20120410/</a> <dt>Implementation Report: <dd><a href="https://wpt.fyi/results/css/css-variables">https://wpt.fyi/results/css/css-variables</a> <dt>Feedback: <dd><a href="https://github.com/w3c/csswg-drafts/labels/css-variables-1">CSSWG Issues Repository</a> <dt class="editor">Editor: <dd class="editor p-author h-card vcard" data-editor-id="42199"><a class="p-name fn u-url url" href="http://xanthir.com/contact">Tab Atkins Jr.</a> (<span class="p-org org">Google</span>) <dt>Suggest an Edit for this Spec: <dd><a href="https://github.com/w3c/csswg-drafts/blob/main/css-variables-1/Overview.bs">GitHub Editor</a> <dt>Test Suite: <dd class="wpt-overview"><a href="https://wpt.fyi/results/css/css-variables/">https://wpt.fyi/results/css/css-variables/</a> </dl> </div> </details> <div data-fill-with="warning"></div> <p class="copyright" data-fill-with="copyright"><a href="https://www.w3.org/policies/#copyright">Copyright</a> © 2025 <a href="https://www.w3.org/">World Wide Web Consortium</a>. <abbr title="World Wide Web Consortium">W3C</abbr><sup>®</sup> <a href="https://www.w3.org/policies/#Legal_Disclaimer">liability</a>, <a href="https://www.w3.org/policies/#W3C_Trademarks">trademark</a> and <a href="https://www.w3.org/copyright/software-license/" rel="license" title="W3C Software and Document License">permissive document license</a> rules apply. </p> <hr title="Separator for header"> </div> <div class="p-summary" data-fill-with="abstract"> <h2 class="no-num no-toc no-ref heading settled" id="abstract"><span class="content">Abstract</span></h2> <p>This module introduces cascading variables as a new primitive value type that is accepted by all CSS properties, and custom properties for defining them.</p> <a href="https://www.w3.org/TR/CSS/">CSS</a> is a language for describing the rendering of structured documents (such as HTML and XML) on screen, on paper, etc. <script> const githubPrefix = "https://w3c.github.io/csswg-drafts/"; if(location.href.slice(0, githubPrefix.length) == githubPrefix) { const suffix = location.href.slice(githubPrefix.length); const draftUrl = "https://drafts.csswg.org/" + suffix; window.location.replace(draftUrl); } </script> </div> <h2 class="no-num no-toc no-ref heading settled" id="sotd"><span class="content">Status of this document</span></h2> <div data-fill-with="status"> <p> This is a public copy of the editors’ draft. It is provided for discussion only and may change at any moment. Its publication here does not imply endorsement of its contents by W3C. Don’t cite this document other than as work in progress. </p> <p>Please send feedback by <a href="https://github.com/w3c/csswg-drafts/issues">filing issues in GitHub</a> (preferred), including the spec code “css-variables” in the title, like this: “[css-variables] <i>…summary of comment…</i>”. All issues and comments are <a href="https://lists.w3.org/Archives/Public/public-css-archive/">archived</a>. Alternately, feedback can be sent to the (<a href="https://lists.w3.org/Archives/Public/www-style/">archived</a>) public mailing list <a href="mailto:www-style@w3.org?Subject=%5Bcss-variables%5D%20PUT%20SUBJECT%20HERE">www-style@w3.org</a>. </p> <p>This document is governed by the <a href="https://www.w3.org/policies/process/20231103/" id="w3c_process_revision">03 November 2023 W3C Process Document</a>. </p> </div> <div data-fill-with="at-risk"></div> <nav data-fill-with="table-of-contents" id="toc"> <h2 class="no-num no-toc no-ref" id="contents">Table of Contents</h2> <ol class="toc" role="directory"> <li> <a href="#intro"><span class="secno">1</span> <span class="content"> Introduction</span></a> <ol class="toc"> <li><a href="#values"><span class="secno">1.1</span> <span class="content"> Value Definitions</span></a> </ol> <li> <a href="#defining-variables"><span class="secno">2</span> <span class="content"> Defining Custom Properties: the <span class="css">--*</span> family of properties</span></a> <ol class="toc"> <li><a href="#syntax"><span class="secno">2.1</span> <span class="content"> Custom Property Value Syntax</span></a> <li><a href="#guaranteed-invalid"><span class="secno">2.2</span> <span class="content"> Guaranteed-Invalid Values</span></a> <li><a href="#cycles"><span class="secno">2.3</span> <span class="content"> Resolving Dependency Cycles</span></a> </ol> <li><a href="#using-variables"><span class="secno">3</span> <span class="content"> Using Cascading Variables: the <span class="css">var()</span> notation</span></a> <li> <a href="#apis"><span class="secno">4</span> <span class="content"> APIs</span></a> <ol class="toc"> <li><a href="#serializing-custom-props"><span class="secno">4.1</span> <span class="content"> Serializing Custom Properties</span></a> </ol> <li> <a href="#changes"><span class="secno">5</span> <span class="content"> Changes</span></a> <ol class="toc"> <li><a href="#changes-20220616"><span class="secno">5.1</span> <span class="content"> Changes Since the 16 June 2022 CR Snapshot</span></a> <li><a href="#changes-20211111"><span class="secno">5.2</span> <span class="content"> Changes Since the 11 November 2021 CR Draft</span></a> <li><a href="#changes-20151203"><span class="secno">5.3</span> <span class="content"> Changes Since the 03 December 2015 CR</span></a> <li><a href="#changes-20140506"><span class="secno">5.4</span> <span class="content"> Changes since the May 6 2014 Last Call Working Draft</span></a> </ol> <li><a href="#acks"><span class="secno">6</span> <span class="content"> Acknowledgments</span></a> <li><a href="#privacy"><span class="secno">7</span> <span class="content">Privacy Considerations</span></a> <li><a href="#security"><span class="secno">8</span> <span class="content">Security Considerations</span></a> <li> <a href="#w3c-conformance"><span class="secno"></span> <span class="content"> Conformance</span></a> <ol class="toc"> <li><a href="#w3c-conventions"><span class="secno"></span> <span class="content"> Document conventions</span></a> <li><a href="#w3c-conformance-classes"><span class="secno"></span> <span class="content"> Conformance classes</span></a> <li> <a href="#w3c-partial"><span class="secno"></span> <span class="content"> Partial implementations</span></a> <ol class="toc"> <li><a href="#w3c-conform-future-proofing"><span class="secno"></span> <span class="content"> Implementations of Unstable and Proprietary Features</span></a> </ol> <li><a href="#w3c-testing"><span class="secno"></span> <span class="content"> Non-experimental implementations</span></a> </ol> <li> <a href="#index"><span class="secno"></span> <span class="content">Index</span></a> <ol class="toc"> <li><a href="#index-defined-here"><span class="secno"></span> <span class="content">Terms defined by this specification</span></a> <li><a href="#index-defined-elsewhere"><span class="secno"></span> <span class="content">Terms defined by reference</span></a> </ol> <li> <a href="#references"><span class="secno"></span> <span class="content">References</span></a> <ol class="toc"> <li><a href="#normative"><span class="secno"></span> <span class="content">Normative References</span></a> <li><a href="#informative"><span class="secno"></span> <span class="content">Informative References</span></a> </ol> <li><a href="#property-index"><span class="secno"></span> <span class="content">Property Index</span></a> </ol> </nav> <main> <h2 class="heading settled" data-level="1" id="intro"><span class="secno">1. </span><span class="content"> Introduction</span><a class="self-link" href="#intro"></a></h2> <p><em>This section is not normative.</em></p> <p>Large documents or applications (and even small ones) can contain quite a bit of CSS. Many of the values in the CSS file will be duplicate data; for example, a site may establish a color scheme and reuse three or four colors throughout the site. Altering this data can be difficult and error-prone, since it’s scattered throughout the CSS file (and possibly across multiple files), and may not be amenable to Find-and-Replace.</p> <p>This module introduces a family of custom author-defined properties known collectively as <a data-link-type="dfn" href="#custom-property" id="ref-for-custom-property">custom properties</a>, which allow an author to assign arbitrary values to a property with an author-chosen name, and the <a class="css" data-link-type="maybe" href="#funcdef-var" id="ref-for-funcdef-var">var()</a> function, which allow an author to then use those values in other properties elsewhere in the document. This makes it easier to read large files, as seemingly-arbitrary values now have informative names, and makes editing such files much easier and less error-prone, as one only has to change the value once, in the <span id="ref-for-custom-property①">custom property</span>, and the change will propagate to all uses of that variable automatically.</p> <h3 class="heading settled" data-level="1.1" id="values"><span class="secno">1.1. </span><span class="content"> Value Definitions</span><a class="self-link" href="#values"></a></h3> <p>This specification follows the <a href="https://www.w3.org/TR/CSS2/about.html#property-defs">CSS property definition conventions</a> from <a data-link-type="biblio" href="#biblio-css2" title="Cascading Style Sheets Level 2 Revision 1 (CSS 2.1) Specification">[CSS2]</a> using the <a href="https://www.w3.org/TR/css-values-3/#value-defs">value definition syntax</a> from <a data-link-type="biblio" href="#biblio-css-values-3" title="CSS Values and Units Module Level 3">[CSS-VALUES-3]</a>. Value types not defined in this specification are defined in CSS Values & Units <span title="CSS Values and Units Module Level 3">[CSS-VALUES-3]</span>. Combination with other CSS modules may expand the definitions of these value types.</p> <p>In addition to the property-specific values listed in their definitions, all properties defined in this specification also accept the <a data-link-type="dfn" href="https://drafts.csswg.org/css-values-4/#css-wide-keywords" id="ref-for-css-wide-keywords">CSS-wide keywords</a> as their property value. For readability they have not been repeated explicitly.</p> <h2 class="heading settled" data-level="2" id="defining-variables"><span class="secno">2. </span><span class="content"> Defining Custom Properties: the <span class="css">--*</span> family of properties</span><a class="self-link" href="#defining-variables"></a></h2> <p>This specification defines an open-ended set of properties called <a data-link-type="dfn" href="#custom-property" id="ref-for-custom-property②">custom properties</a>, which, among other things, are used to define the <a data-link-type="dfn" href="https://drafts.csswg.org/css-values-5/#substitute-arbitrary-substitution-function" id="ref-for-substitute-arbitrary-substitution-function">substitution value</a> of <a class="css" data-link-type="maybe" href="#funcdef-var" id="ref-for-funcdef-var①">var()</a> functions.</p> <table class="def propdef" data-link-for-hint="--*"> <tbody> <tr> <th>Name: <td><dfn class="dfn-paneled css" data-dfn-type="property" data-export id="propdef-">--*</dfn> <tr class="value"> <th><a href="https://www.w3.org/TR/css-values/#value-defs">Value:</a> <td class="prod"><a class="production css" data-link-type="type" href="https://drafts.csswg.org/css-syntax-3/#typedef-declaration-value" id="ref-for-typedef-declaration-value"><declaration-value></a><a data-link-type="grammar" href="https://drafts.csswg.org/css-values-4/#mult-opt" id="ref-for-mult-opt">?</a> <tr> <th><a href="https://www.w3.org/TR/css-cascade/#initial-values">Initial:</a> <td>the <a data-link-type="dfn" href="#guaranteed-invalid-value" id="ref-for-guaranteed-invalid-value">guaranteed-invalid value</a> <tr> <th><a href="https://www.w3.org/TR/css-cascade/#applies-to">Applies to:</a> <td>all elements and all pseudo-elements (including those with restricted property lists) <tr> <th><a href="https://www.w3.org/TR/css-cascade/#inherited-property">Inherited:</a> <td>yes <tr> <th><a href="https://www.w3.org/TR/css-values/#percentages">Percentages:</a> <td>n/a <tr> <th><a href="https://www.w3.org/TR/css-cascade/#computed">Computed value:</a> <td>specified value with variables substituted, or the <a data-link-type="dfn" href="#guaranteed-invalid-value" id="ref-for-guaranteed-invalid-value①">guaranteed-invalid value</a> <tr> <th><a href="https://www.w3.org/TR/cssom/#serializing-css-values">Canonical order:</a> <td>per grammar <tr> <th><a href="https://www.w3.org/TR/web-animations/#animation-type">Animation type:</a> <td>discrete </table> <p class="all-media">User agents are expected to support this property on all media, including non-visual ones.</p> <p>A <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="custom-property">custom property</dfn> is any property whose name starts with two dashes (U+002D HYPHEN-MINUS), like <span class="css">--foo</span>. The <dfn class="dfn-paneled css" data-dfn-type="type" data-export id="typedef-custom-property-name"><custom-property-name></dfn> production corresponds to this: it’s defined as any <a class="production css" data-link-type="type" href="https://drafts.csswg.org/css-values-4/#typedef-dashed-ident" id="ref-for-typedef-dashed-ident"><dashed-ident></a> (a valid <a data-link-type="dfn" href="https://drafts.csswg.org/css-values-4/#css-css-identifier" id="ref-for-css-css-identifier">identifier</a> that starts with two dashes), except <span class="css">--</span> itself, which is reserved for future use by CSS. <a data-link-type="dfn" href="#custom-property" id="ref-for-custom-property③">Custom properties</a> are solely for use by authors and users; CSS will never give them a meaning beyond what is presented here.</p> <details class="wpt-tests-block" dir="ltr" lang="en"> <summary>Tests</summary> <ul class="wpt-tests-list"> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-declaration-29.html" title="css/css-variables/variable-declaration-29.html">variable-declaration-29.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-declaration-29.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-declaration-29.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-declaration-31.html" title="css/css-variables/variable-declaration-31.html">variable-declaration-31.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-declaration-31.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-declaration-31.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-declaration-32.html" title="css/css-variables/variable-declaration-32.html">variable-declaration-32.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-declaration-32.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-declaration-32.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-declaration-33.html" title="css/css-variables/variable-declaration-33.html">variable-declaration-33.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-declaration-33.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-declaration-33.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-declaration-34.html" title="css/css-variables/variable-declaration-34.html">variable-declaration-34.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-declaration-34.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-declaration-34.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-declaration-35.html" title="css/css-variables/variable-declaration-35.html">variable-declaration-35.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-declaration-35.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-declaration-35.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-declaration-36.html" title="css/css-variables/variable-declaration-36.html">variable-declaration-36.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-declaration-36.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-declaration-36.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-declaration-40.html" title="css/css-variables/variable-declaration-40.html">variable-declaration-40.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-declaration-40.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-declaration-40.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-declaration-41.html" title="css/css-variables/variable-declaration-41.html">variable-declaration-41.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-declaration-41.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-declaration-41.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-declaration-42.html" title="css/css-variables/variable-declaration-42.html">variable-declaration-42.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-declaration-42.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-declaration-42.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-empty-name-reserved.html" title="css/css-variables/variable-empty-name-reserved.html">variable-empty-name-reserved.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-empty-name-reserved.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-empty-name-reserved.html"><small>(source)</small></a> </ul> </details> <div class="example" id="example-81b6bcdd"> <a class="self-link" href="#example-81b6bcdd"></a> Custom properties define variables, referenced with the <a class="css" data-link-type="maybe" href="#funcdef-var" id="ref-for-funcdef-var②">var()</a> notation, which can be used for many purposes. For example, a page that consistently uses a small set of colors in its design can store the colors in custom properties and use them with variables: <pre class="highlight">:root <c- p>{</c-> <c- k>--main-color</c-><c- p>:</c-> #06c<c- p>;</c-> <c- k>--accent-color</c-><c- p>:</c-> #006<c- p>;</c-> <c- p>}</c-> <c- c>/* The rest of the CSS file */</c-> #foo h1 <c- p>{</c-> <c- k>color</c-><c- p>:</c-> <c- nf>var</c-><c- p>(</c->--main-color<c- p>);</c-> <c- p>}</c-> </pre> <p>The naming provides a mnemonic for the colors, prevents difficult-to-spot typos in the color codes, and if the theme colors are ever changed, focuses the change on one simple spot (the custom property value) rather than requiring many edits across all stylesheets in the webpage.</p> </div> <p>Unlike other CSS properties, custom property names are <em>not</em> <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" id="ref-for-ascii-case-insensitive">ASCII case-insensitive</a>. Instead, custom property names are only equal to each other if they are <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#string-is" id="ref-for-string-is">identical to</a> each other.</p> <details class="wpt-tests-block" dir="ltr" lang="en"> <summary>Tests</summary> <ul class="wpt-tests-list"> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/css-vars-custom-property-case-sensitive-001.html" title="css/css-variables/css-vars-custom-property-case-sensitive-001.html">css-vars-custom-property-case-sensitive-001.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/css-vars-custom-property-case-sensitive-001.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/css-vars-custom-property-case-sensitive-001.html"><small>(source)</small></a> </ul> </details> <div class="example" id="example-c4b03623"> <a class="self-link" href="#example-c4b03623"></a> While both <span class="css">--foo</span> and <span class="css">--FOO</span> are valid, they are distinct properties —using <span class="css">var(--foo)</span> will refer to the first one, while using <span class="css">var(--FOO)</span> will refer to the second. <p>Perhaps more surprisingly, <span class="css">--foó</span> and <span class="css">--foó</span> are distinct properties. The first is spelled with U+00F3 (LATIN SMALL LETTER O WITH ACUTE) while the second is spelled with an ASCII "o" followed by U+0301 (COMBINING ACUTE ACCENT), and the "<a data-link-type="dfn" href="https://infra.spec.whatwg.org/#string-is" id="ref-for-string-is①">identical to</a>" relation uses direct codepoint-by-codepoint comparison to determine if two strings are equal, to avoid the complexities and pitfalls of unicode normalization and locale-specific collation.</p> </div> <p>Operating systems, keyboards, or input methods sometimes encode visually-identical text using different codepoint sequences. Authors are advised to choose variable names that avoid potential confusion or to use escapes and other means to ensure that similar appearing sequences are identical. See Section 2.3 in <a data-link-type="biblio" href="#biblio-charmod-norm" title="Character Model for the World Wide Web: String Matching">[CHARMOD-NORM]</a> for examples.</p> <div class="example" id="example-120efb12"> <a class="self-link" href="#example-120efb12"></a> Developers maintaining the following CSS might be confused why the test patch is red: <pre class="highlight"><c- k>--fijord</c-><c- p>:</c-> red<c- p>;</c-> <c- k>--fijord</c-><c- p>:</c-> green<c- p>;</c-> <c- k>--fijord</c-><c- p>:</c-> blue<c- p>;</c-> .test <c- p>{</c-> <c- k>background-color</c-><c- p>:</c-> <c- nf>var</c-><c- p>(</c->--fijord<c- p>);</c-> <c- p>}</c-> </pre> <p>The reason is that the first custom property uses the character sequence LATIN SMALL LETTER F + LATIN SMALL LETTER I + LATIN SMALL LETTER J; the second, identical-looking one uses the character sequence LATIN SMALL LETTER F + LATIN SMALL LIGATURE IJ while the third uses the character sequence LATIN SMALL LIGATURE FI + LATIN SMALL LETTER J.</p> <p>So the CSS contains three distinct custom properties, two of which are unused.</p> </div> <p>Custom properties are <strong>not</strong> reset by the <a class="property css" data-link-type="property" href="https://drafts.csswg.org/css-cascade-5/#propdef-all" id="ref-for-propdef-all">all</a> property. <span class="note">We may define a property in the future that resets all variables.</span></p> <p>The <a data-link-type="dfn" href="https://drafts.csswg.org/css-values-4/#css-wide-keywords" id="ref-for-css-wide-keywords①">CSS-wide keywords</a> can be used in custom properties, with the same meaning as in any another property.</p> <details class="wpt-tests-block" dir="ltr" lang="en"> <summary>Tests</summary> <ul class="wpt-tests-list"> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-declaration-43.html" title="css/css-variables/variable-declaration-43.html">variable-declaration-43.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-declaration-43.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-declaration-43.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-declaration-44.html" title="css/css-variables/variable-declaration-44.html">variable-declaration-44.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-declaration-44.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-declaration-44.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-declaration-45.html" title="css/css-variables/variable-declaration-45.html">variable-declaration-45.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-declaration-45.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-declaration-45.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-declaration-46.html" title="css/css-variables/variable-declaration-46.html">variable-declaration-46.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-declaration-46.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-declaration-46.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-declaration-47.html" title="css/css-variables/variable-declaration-47.html">variable-declaration-47.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-declaration-47.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-declaration-47.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-declaration-56.html" title="css/css-variables/variable-declaration-56.html">variable-declaration-56.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-declaration-56.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-declaration-56.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-declaration-57.html" title="css/css-variables/variable-declaration-57.html">variable-declaration-57.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-declaration-57.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-declaration-57.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-declaration-58.html" title="css/css-variables/variable-declaration-58.html">variable-declaration-58.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-declaration-58.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-declaration-58.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-declaration-60.html" title="css/css-variables/variable-declaration-60.html">variable-declaration-60.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-declaration-60.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-declaration-60.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-definition-keywords.html" title="css/css-variables/variable-definition-keywords.html">variable-definition-keywords.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-definition-keywords.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-definition-keywords.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-css-wide-keywords.html" title="css/css-variables/variable-css-wide-keywords.html">variable-css-wide-keywords.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-css-wide-keywords.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-css-wide-keywords.html"><small>(source)</small></a> </ul> </details> <p class="note" role="note"><span class="marker">Note:</span> That is, they’re interpreted at cascaded-value time as normal, and are not preserved as the custom property’s value, and thus are not substituted in by the corresponding variable.</p> <p class="note" role="note"><span class="marker">Note:</span> While this module focuses on the use of <a data-link-type="dfn" href="#custom-property" id="ref-for-custom-property④">custom properties</a> with the <a class="css" data-link-type="maybe" href="#funcdef-var" id="ref-for-funcdef-var③">var()</a> function to create “variables”, they can also be used as actual custom properties, parsed by and acted on by script. It’s expected that the CSS Extensions spec <a data-link-type="biblio" href="#biblio-css-extensions" title="CSS Extensions">[CSS-EXTENSIONS]</a> will expand on these use-cases and make them easier to do.</p> <p>Custom properties are ordinary properties, so they can be declared on any element, are resolved with the normal inheritance and cascade rules, can be made conditional with <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-conditional-3/#at-ruledef-media" id="ref-for-at-ruledef-media">@media</a> and other conditional rules, can be used in HTML’s <code class="highlight">style</code> attribute, can be read or set using the CSSOM, etc.</p> <details class="wpt-tests-block" dir="ltr" lang="en"> <summary>Tests</summary> <ul class="wpt-tests-list"> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/css-vars-custom-property-inheritance.html" title="css/css-variables/css-vars-custom-property-inheritance.html">css-vars-custom-property-inheritance.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/css-vars-custom-property-inheritance.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/css-vars-custom-property-inheritance.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-created-document.html" title="css/css-variables/variable-created-document.html">variable-created-document.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-created-document.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-created-document.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-created-element.html" title="css/css-variables/variable-created-element.html">variable-created-element.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-created-element.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-created-element.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-cssText.html" title="css/css-variables/variable-cssText.html">variable-cssText.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-cssText.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-cssText.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-declaration-06.html" title="css/css-variables/variable-declaration-06.html">variable-declaration-06.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-declaration-06.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-declaration-06.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-definition-cascading.html" title="css/css-variables/variable-definition-cascading.html">variable-definition-cascading.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-definition-cascading.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-definition-cascading.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-external-declaration-01.html" title="css/css-variables/variable-external-declaration-01.html">variable-external-declaration-01.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-external-declaration-01.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-external-declaration-01.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-external-reference-01.html" title="css/css-variables/variable-external-reference-01.html">variable-external-reference-01.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-external-reference-01.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-external-reference-01.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-external-supports-01.html" title="css/css-variables/variable-external-supports-01.html">variable-external-supports-01.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-external-supports-01.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-external-supports-01.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-first-letter.html" title="css/css-variables/variable-first-letter.html">variable-first-letter.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-first-letter.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-first-letter.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-first-line.html" title="css/css-variables/variable-first-line.html">variable-first-line.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-first-line.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-first-line.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-pseudo-element.html" title="css/css-variables/variable-pseudo-element.html">variable-pseudo-element.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-pseudo-element.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-pseudo-element.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-reference-13.html" title="css/css-variables/variable-reference-13.html">variable-reference-13.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-reference-13.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-reference-13.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-reference-14.html" title="css/css-variables/variable-reference-14.html">variable-reference-14.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-reference-14.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-reference-14.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-reference-shorthands.html" title="css/css-variables/variable-reference-shorthands.html">variable-reference-shorthands.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-reference-shorthands.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-reference-shorthands.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-reference-visited.html" title="css/css-variables/variable-reference-visited.html">variable-reference-visited.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-reference-visited.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-reference-visited.html"><small>(source)</small></a> </ul> </details> <p>Notably, they can even be animated, but since the UA has no way to interpret their contents, they always use the "flips at 50%" behavior that is used for any other pair of values that can’t be intelligently interpolated. However, any <a data-link-type="dfn" href="#custom-property" id="ref-for-custom-property⑤">custom property</a> used in a <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-animations-1/#at-ruledef-keyframes" id="ref-for-at-ruledef-keyframes">@keyframes</a> rule becomes <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport id="animation-tainted">animation-tainted</dfn>, which affects how it is treated when referred to via the <a class="css" data-link-type="maybe" href="#funcdef-var" id="ref-for-funcdef-var④">var()</a> function in an animation property.</p> <details class="wpt-tests-block" dir="ltr" lang="en"> <summary>Tests</summary> <ul class="wpt-tests-list"> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-animation-from-to.html" title="css/css-variables/variable-animation-from-to.html">variable-animation-from-to.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-animation-from-to.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-animation-from-to.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-animation-over-transition.html" title="css/css-variables/variable-animation-over-transition.html">variable-animation-over-transition.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-animation-over-transition.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-animation-over-transition.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-animation-substitute-into-keyframe-shorthand.html" title="css/css-variables/variable-animation-substitute-into-keyframe-shorthand.html">variable-animation-substitute-into-keyframe-shorthand.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-animation-substitute-into-keyframe-shorthand.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-animation-substitute-into-keyframe-shorthand.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-animation-substitute-into-keyframe-transform.html" title="css/css-variables/variable-animation-substitute-into-keyframe-transform.html">variable-animation-substitute-into-keyframe-transform.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-animation-substitute-into-keyframe-transform.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-animation-substitute-into-keyframe-transform.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-animation-substitute-into-keyframe.html" title="css/css-variables/variable-animation-substitute-into-keyframe.html">variable-animation-substitute-into-keyframe.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-animation-substitute-into-keyframe.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-animation-substitute-into-keyframe.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-animation-substitute-within-keyframe-fallback.html" title="css/css-variables/variable-animation-substitute-within-keyframe-fallback.html">variable-animation-substitute-within-keyframe-fallback.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-animation-substitute-within-keyframe-fallback.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-animation-substitute-within-keyframe-fallback.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-animation-substitute-within-keyframe-multiple.html" title="css/css-variables/variable-animation-substitute-within-keyframe-multiple.html">variable-animation-substitute-within-keyframe-multiple.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-animation-substitute-within-keyframe-multiple.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-animation-substitute-within-keyframe-multiple.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-animation-substitute-within-keyframe.html" title="css/css-variables/variable-animation-substitute-within-keyframe.html">variable-animation-substitute-within-keyframe.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-animation-substitute-within-keyframe.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-animation-substitute-within-keyframe.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-animation-to-only.html" title="css/css-variables/variable-animation-to-only.html">variable-animation-to-only.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-animation-to-only.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-animation-to-only.html"><small>(source)</small></a> </ul> </details> <p class="note" role="note"><span class="marker">Note:</span> Like any other property that animates discretely, custom properties can’t be transitioned. <a data-link-type="dfn" href="https://drafts.css-houdini.org/css-properties-values-api-1/#registered-custom-property" id="ref-for-registered-custom-property">Registered custom properties</a> can, however, if given a syntax that has non-discrete animation behavior.</p> <p><a data-link-type="dfn" href="#animation-tainted" id="ref-for-animation-tainted">Animation-tainted</a> is "infectious": custom properties which reference <span id="ref-for-animation-tainted①">animation-tainted</span> properties also become <span id="ref-for-animation-tainted②">animation-tainted</span>.</p> <div class="example" id="example-d6247b0f"> <a class="self-link" href="#example-d6247b0f"></a> This style rule: <pre class="highlight">:root <c- p>{</c-> <c- k>--header-color</c-><c- p>:</c-> #06c<c- p>;</c-> <c- p>}</c-> </pre> <p>declares a <a data-link-type="dfn" href="#custom-property" id="ref-for-custom-property⑥">custom property</a> named <span class="css">--header-color</span> on the root element, and assigns to it the value "#06c". This property is then inherited to the elements in the rest of the document. Its value can be referenced with the <a class="css" data-link-type="maybe" href="#funcdef-var" id="ref-for-funcdef-var⑤">var()</a> function:</p> <pre class="highlight">h1 <c- p>{</c-> <c- k>background-color</c-><c- p>:</c-> <c- nf>var</c-><c- p>(</c->--header-color<c- p>);</c-> <c- p>}</c-> </pre> <p>The preceding rule is equivalent to writing <a class="css" data-link-type="propdesc" href="https://drafts.csswg.org/css-backgrounds-3/#propdef-background-color" id="ref-for-propdef-background-color">background-color: #06c;</a>, except that the variable name makes the origin of the color clearer, and if <span class="css">var(--header-color)</span> is used on other elements in the document, all of the uses can be updated at once by changing the <span class="css">--header-color</span> property on the root element.</p> </div> <div class="example" id="example-c3e4e8d9"> <a class="self-link" href="#example-c3e4e8d9"></a> If a <a data-link-type="dfn" href="#custom-property" id="ref-for-custom-property⑦">custom property</a> is declared multiple times, the standard cascade rules help resolve it. Variables always draw from the computed value of the associated custom property on the same element: <pre class="highlight">:root <c- p>{</c-> <c- k>--color</c-><c- p>:</c-> blue<c- p>;</c-> <c- p>}</c-> div <c- p>{</c-> <c- k>--color</c-><c- p>:</c-> green<c- p>;</c-> <c- p>}</c-> #alert <c- p>{</c-> <c- k>--color</c-><c- p>:</c-> red<c- p>;</c-> <c- p>}</c-> * <c- p>{</c-> <c- k>color</c-><c- p>:</c-> <c- nf>var</c-><c- p>(</c->--color<c- p>);</c-> <c- p>}</c-> <p><span style="color: blue">I inherited blue from the root element!</span></p> <div><span style="color: green">I got green set directly on me!</span></div> <div id=<c- s>'alert'</c->> <span style="color: red">While I got red set directly on me!</span> <p><span style="color: red">I’m red too<c- p>,</c-> because of inheritance!</span></p> </div> </pre> </div> <div class="example" id="example-8f013eba"> <a class="self-link" href="#example-8f013eba"></a> A real-world example of <a data-link-type="dfn" href="#custom-property" id="ref-for-custom-property⑧">custom property</a> usage is easily separating out strings from where they’re used, to aid in maintenance of internationalization: <pre class="lang-css highlight">:root<c- p>,</c-> :root<c- nf>:lang</c-><c- p>(</c->en<c- p>)</c-> <c- p>{</c-><c- k>--external-link</c-><c- p>:</c-> <c- s>"external link"</c-><c- p>;}</c-> :root<c- nf>:lang</c-><c- p>(</c->el<c- p>)</c-> <c- p>{</c-><c- k>--external-link</c-><c- p>:</c-> <c- s>"εξωτερικός σύνδεσμος"</c-><c- p>;}</c-> a<c- p>[</c->href^=<c- s>"http"</c-><c- p>]</c->::after <c- p>{</c-><c- k>content</c-><c- p>:</c-> <c- s>" ("</c-> <c- nf>var</c-><c- p>(</c->--external-link<c- p>)</c-> <c- s>")"</c-><c- p>}</c-> </pre> <p>The variable declarations can even be kept in a separate file, to make maintaining the translations simpler.</p> </div> <h3 class="heading settled" data-level="2.1" id="syntax"><span class="secno">2.1. </span><span class="content"> Custom Property Value Syntax</span><a class="self-link" href="#syntax"></a></h3> <p>The allowed syntax for <a data-link-type="dfn" href="#custom-property" id="ref-for-custom-property⑨">custom properties</a> is extremely permissive. The <a class="production css" data-link-type="type" href="https://drafts.csswg.org/css-syntax-3/#typedef-declaration-value" id="ref-for-typedef-declaration-value①"><declaration-value></a> production matches <em>any</em> sequence of one or more tokens, so long as the sequence does not contain <a class="production css" data-link-type="type" href="https://drafts.csswg.org/css-syntax-3/#typedef-bad-string-token" id="ref-for-typedef-bad-string-token"><bad-string-token></a>, <a class="production css" data-link-type="type" href="https://drafts.csswg.org/css-syntax-3/#typedef-bad-url-token" id="ref-for-typedef-bad-url-token"><bad-url-token></a>, unmatched <a class="production css" data-link-type="type" href="https://drafts.csswg.org/css-syntax-3/#tokendef-close-paren" id="ref-for-tokendef-close-paren"><)-token></a>, <a class="production css" data-link-type="type" href="https://drafts.csswg.org/css-syntax-3/#tokendef-close-square" id="ref-for-tokendef-close-square"><]-token></a>, or <a class="production css" data-link-type="type" href="https://drafts.csswg.org/css-syntax-3/#tokendef-close-curly" id="ref-for-tokendef-close-curly"><}-token></a>, or top-level <a class="production css" data-link-type="type" href="https://drafts.csswg.org/css-syntax-3/#typedef-semicolon-token" id="ref-for-typedef-semicolon-token"><semicolon-token></a> tokens or <a class="production css" data-link-type="type" href="https://drafts.csswg.org/css-syntax-3/#typedef-delim-token" id="ref-for-typedef-delim-token"><delim-token></a> tokens with a value of "!".</p> <details class="wpt-tests-block" dir="ltr" lang="en"> <summary>Tests</summary> <ul class="wpt-tests-list"> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/long-variable-reference-crash.html" title="css/css-variables/long-variable-reference-crash.html">long-variable-reference-crash.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/long-variable-reference-crash.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/long-variable-reference-crash.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/test_variable_legal_values.html" title="css/css-variables/test_variable_legal_values.html">test_variable_legal_values.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/test_variable_legal_values.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/test_variable_legal_values.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-declaration-15.html" title="css/css-variables/variable-declaration-15.html">variable-declaration-15.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-declaration-15.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-declaration-15.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-declaration-24.html" title="css/css-variables/variable-declaration-24.html">variable-declaration-24.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-declaration-24.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-declaration-24.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-declaration-25.html" title="css/css-variables/variable-declaration-25.html">variable-declaration-25.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-declaration-25.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-declaration-25.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-declaration-26.html" title="css/css-variables/variable-declaration-26.html">variable-declaration-26.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-declaration-26.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-declaration-26.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-declaration-59.html" title="css/css-variables/variable-declaration-59.html">variable-declaration-59.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-declaration-59.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-declaration-59.html"><small>(source)</small></a> </ul> </details> <p>In addition, if the value of a <a data-link-type="dfn" href="#custom-property" id="ref-for-custom-property①⓪">custom property</a> contains a <a class="css" data-link-type="maybe" href="#funcdef-var" id="ref-for-funcdef-var⑥">var()</a> reference, the <span class="css" id="ref-for-funcdef-var⑦">var()</span> reference must be valid according to the specified <span class="css" id="ref-for-funcdef-var⑧">var()</span> grammar. If not, the <span id="ref-for-custom-property①①">custom property</span> is invalid and must be ignored.</p> <p class="note" role="note"><span class="marker">Note:</span> This definition, along with the general CSS syntax rules, implies that a custom property value never includes an unmatched quote or bracket, and so cannot have any effect on larger syntax constructs, like the enclosing style rule, when reserialized.</p> <p class="note" role="note"><span class="marker">Note:</span> Custom properties can contain a trailing <span class="css">!important</span>, but this is automatically removed from the property’s value by the CSS parser, and makes the custom property "important" in the CSS cascade. In other words, the prohibition on top-level "!" characters does not prevent <span class="css">!important</span> from being used, as the <span class="css">!important</span> is removed before syntax checking happens.</p> <details class="wpt-tests-block" dir="ltr" lang="en"> <summary>Tests</summary> <ul class="wpt-tests-list"> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-declaration-20.html" title="css/css-variables/variable-declaration-20.html">variable-declaration-20.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-declaration-20.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-declaration-20.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-declaration-23.html" title="css/css-variables/variable-declaration-23.html">variable-declaration-23.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-declaration-23.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-declaration-23.html"><small>(source)</small></a> </ul> </details> <div class="example" id="example-fb41560d"> <a class="self-link" href="#example-fb41560d"></a> For example, the following is a valid custom property: <pre class="highlight"><c- k>--foo</c-><c- p>:</c-> <c- nf>if</c-><c- p>(</c->x > <c- m>5</c-><c- p>)</c-> this.width = <c- m>10</c-><c- p>;</c-> </pre> <p>While this value is obviously useless as a <em>variable</em>, as it would be invalid in any normal property, it might be read and acted on by JavaScript.</p> </div> <p>The values of custom properties, and the values of <a class="css" data-link-type="maybe" href="#funcdef-var" id="ref-for-funcdef-var⑨">var()</a> functions substituted into custom properties, are <em>case-sensitive</em>, and must be preserved in their original author-given casing. (Many CSS values are <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" id="ref-for-ascii-case-insensitive①">ASCII case-insensitive</a>, which user agents can take advantage of by "canonicalizing" them into a single casing, but that isn’t allowed for custom properties.)</p> <details class="wpt-tests-block" dir="ltr" lang="en"> <summary>Tests</summary> <ul class="wpt-tests-list"> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-declaration-38.html" title="css/css-variables/variable-declaration-38.html">variable-declaration-38.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-declaration-38.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-declaration-38.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-declaration-39.html" title="css/css-variables/variable-declaration-39.html">variable-declaration-39.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-declaration-39.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-declaration-39.html"><small>(source)</small></a> </ul> </details> <div class="note" role="note"> Because custom properties can contain <em>anything</em>, there is no general way to know how to interpret what’s inside of them (until they’re substituted into a known property with <a class="css" data-link-type="maybe" href="#funcdef-var" id="ref-for-funcdef-var①⓪">var()</a>). Rather than have them <em>partially</em> resolve in some cases but not others, they’re left completely unresolved; they’re a bare stream of <a href="https://drafts.csswg.org/css-syntax-3/#tokenization">CSS tokens</a> interspersed with <span class="css" id="ref-for-funcdef-var①①">var()</span> functions. <p>This has some knock-on implications. For example, relative URLs in CSS are resolved against the base URL of the stylesheet the value appears in. However, if a custom property like <a class="css" data-link-type="propdesc">--my-image: url(foo.jpg);</a> shows up in an <code class="highlight"><c- s>"/a/style.css"</c-></code> stylesheet, it will not resolve into an absolute URL immediately; if that variable is later used in a <em>different</em> <code class="highlight"><c- s>"/b/style.css"</c-></code> stylesheet like <a class="css" data-link-type="propdesc" href="https://drafts.csswg.org/css-backgrounds-3/#propdef-background" id="ref-for-propdef-background">background: var(--my-image);</a>, it will resolve <em>at that point</em> to <code class="highlight"><c- s>"/b/foo.jpg"</c-></code>.</p> </div> <h3 class="heading settled" data-level="2.2" id="guaranteed-invalid"><span class="secno">2.2. </span><span class="content"> Guaranteed-Invalid Values</span><a class="self-link" href="#guaranteed-invalid"></a></h3> <p>The initial value of a <a data-link-type="dfn" href="#custom-property" id="ref-for-custom-property①②">custom property</a> is a <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="guaranteed-invalid-value">guaranteed-invalid value</dfn>.</p> <p>The <a data-link-type="dfn" href="#guaranteed-invalid-value" id="ref-for-guaranteed-invalid-value②">guaranteed-invalid value</a> is, well, guaranteed to be invalid. If it ever appears in a property value, then at <a data-link-type="dfn" href="https://drafts.csswg.org/css-cascade-5/#computed-value" id="ref-for-computed-value">computed value</a> time that property becomes <a data-link-type="dfn" href="https://drafts.csswg.org/css-values-5/#invalid-at-computed-value-time" id="ref-for-invalid-at-computed-value-time">invalid at computed-value time</a>.</p> <p>Non-property contexts will define their own behavior for the <a data-link-type="dfn" href="#guaranteed-invalid-value" id="ref-for-guaranteed-invalid-value③">guaranteed-invalid value</a>, but it will always be "invalid" in some sense.</p> <p>The <a data-link-type="dfn" href="#guaranteed-invalid-value" id="ref-for-guaranteed-invalid-value④">guaranteed-invalid value</a> serializes as the empty string, but actually writing an empty value into a custom property, like <span style=";white-space:nowrap"><span class="css">--foo:;</span></span>, is a valid (empty) value, not the <span id="ref-for-guaranteed-invalid-value⑤">guaranteed-invalid value</span>. If, for whatever reason, one wants to manually reset a <a data-link-type="dfn" href="#custom-property" id="ref-for-custom-property①③">custom property</a> to the <span id="ref-for-guaranteed-invalid-value⑥">guaranteed-invalid value</span>, using the keyword <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-cascade-5/#valdef-all-initial" id="ref-for-valdef-all-initial">initial</a> will do this.</p> <p class="note" role="note"><span class="marker">Note:</span> Other than invoking the <a data-link-type="dfn" href="https://drafts.csswg.org/css-cascade-5/#initial-value" id="ref-for-initial-value">initial value</a> of a non-registered <a data-link-type="dfn" href="#custom-property" id="ref-for-custom-property①④">custom property</a>, the only way to create the <a data-link-type="dfn" href="#guaranteed-invalid-value" id="ref-for-guaranteed-invalid-value⑦">guaranteed-invalid value</a> is by having an invalid <a data-link-type="dfn" href="https://drafts.csswg.org/css-values-5/#arbitrary-substitution-function" id="ref-for-arbitrary-substitution-function">arbitrary substitution function</a>.</p> <h3 class="heading settled" data-level="2.3" id="cycles"><span class="secno">2.3. </span><span class="content"> Resolving Dependency Cycles</span><a class="self-link" href="#cycles"></a></h3> <p><a data-link-type="dfn" href="#custom-property" id="ref-for-custom-property①⑤">Custom properties</a> are left almost entirely unevaluated, except that they allow and evaluate the <a class="css" data-link-type="maybe" href="#funcdef-var" id="ref-for-funcdef-var①②">var()</a> function in their value. This can create cyclic dependencies where a custom property uses a <span class="css" id="ref-for-funcdef-var①③">var()</span> referring to itself, or two or more <span id="ref-for-custom-property①⑥">custom properties</span> each attempt to refer to each other.</p> <p>For each element, create a directed dependency graph, containing nodes for each <a data-link-type="dfn" href="#custom-property" id="ref-for-custom-property①⑦">custom property</a>. If the value of a <span id="ref-for-custom-property①⑧">custom property</span> <var>prop</var> contains a <a class="css" data-link-type="maybe" href="#funcdef-var" id="ref-for-funcdef-var①④">var()</a> function referring to the property <var>var</var> (including in the fallback argument of <span class="css" id="ref-for-funcdef-var①⑤">var()</span>), add an edge between <var>prop</var> and the <var>var</var>. <span class="note">Edges are possible from a custom property to itself.</span></p> <p>If there is a cycle in the dependency graph, all the <a data-link-type="dfn" href="#custom-property" id="ref-for-custom-property①⑨">custom properties</a> in the cycle are <a data-link-type="dfn" href="https://drafts.csswg.org/css-values-5/#invalid-at-computed-value-time" id="ref-for-invalid-at-computed-value-time①">invalid at computed-value time</a>.</p> <details class="wpt-tests-block" dir="ltr" lang="en"> <summary>Tests</summary> <ul class="wpt-tests-list"> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-cycles.html" title="css/css-variables/variable-cycles.html">variable-cycles.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-cycles.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-cycles.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-declaration-30.html" title="css/css-variables/variable-declaration-30.html">variable-declaration-30.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-declaration-30.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-declaration-30.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-declaration-48.html" title="css/css-variables/variable-declaration-48.html">variable-declaration-48.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-declaration-48.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-declaration-48.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-declaration-49.html" title="css/css-variables/variable-declaration-49.html">variable-declaration-49.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-declaration-49.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-declaration-49.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-declaration-50.html" title="css/css-variables/variable-declaration-50.html">variable-declaration-50.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-declaration-50.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-declaration-50.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-reference-39.html" title="css/css-variables/variable-reference-39.html">variable-reference-39.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-reference-39.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-reference-39.html"><small>(source)</small></a> </ul> </details> <p class="note" role="note"><span class="marker">Note:</span> Defined properties that participate in a dependency cycle either end up with invalid variables in their value (becoming <a data-link-type="dfn" href="https://drafts.csswg.org/css-values-5/#invalid-at-computed-value-time" id="ref-for-invalid-at-computed-value-time②">invalid at computed-value time</a>), or define their own cyclic handling (like <a class="property css" data-link-type="property" href="https://drafts.csswg.org/css-fonts-4/#propdef-font-size" id="ref-for-propdef-font-size">font-size</a> using <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-values-4/#em" id="ref-for-em">em</a> values). They do not compute to the <a data-link-type="dfn" href="#guaranteed-invalid-value" id="ref-for-guaranteed-invalid-value⑧">guaranteed-invalid value</a> like custom properties do.</p> <div class="example" id="example-75bf73fb"> <a class="self-link" href="#example-75bf73fb"></a> This example shows a custom property safely using a variable: <pre class="highlight">:root <c- p>{</c-> <c- k>--main-color</c-><c- p>:</c-> #c06<c- p>;</c-> <c- k>--accent-background</c-><c- p>:</c-> <c- nf>linear-gradient</c-><c- p>(</c->to top<c- p>,</c-> <c- nf>var</c-><c- p>(</c->--main-color<c- p>),</c-> white<c- p>);</c-> <c- p>}</c-> </pre> <p>The <span class="css">--accent-background</span> property (along with any other properties that use <span class="css">var(--main-color)</span>) will automatically update when the <span class="css">--main-color</span> property is changed.</p> </div> <div class="example invalid-example" id="example-b8947a2b"> <a class="self-link" href="#example-b8947a2b"></a> On the other hand, this example shows an invalid instance of variables depending on each other: <pre class="highlight">:root <c- p>{</c-> <c- k>--one</c-><c- p>:</c-> <c- nf>calc</c-><c- p>(</c-><c- nf>var</c-><c- p>(</c->--two<c- p>)</c-> + <c- m>20</c-><c- k>px</c-><c- p>);</c-> <c- k>--two</c-><c- p>:</c-> <c- nf>calc</c-><c- p>(</c-><c- nf>var</c-><c- p>(</c->--one<c- p>)</c-> - <c- m>20</c-><c- k>px</c-><c- p>);</c-> <c- p>}</c-> </pre> <p>Both <span class="css">--one</span> and <span class="css">--two</span> are now <a data-link-type="dfn" href="https://drafts.csswg.org/css-values-5/#invalid-at-computed-value-time" id="ref-for-invalid-at-computed-value-time③">invalid at computed-value time</a>, and compute to the <a data-link-type="dfn" href="#guaranteed-invalid-value" id="ref-for-guaranteed-invalid-value⑨">guaranteed-invalid value</a> rather than lengths.</p> </div> <p>It is important to note that <a data-link-type="dfn" href="#custom-property" id="ref-for-custom-property②⓪">custom properties</a> resolve any <a class="css" data-link-type="maybe" href="#funcdef-var" id="ref-for-funcdef-var①⑥">var()</a> functions in their values at computed-value time, which occurs <em>before</em> the value is inherited. In general, cyclic dependencies occur only when multiple custom properties on the same element refer to each other; custom properties defined on elements higher in the element tree can never cause a cyclic reference with properties defined on elements lower in the element tree.</p> <details class="wpt-tests-block" dir="ltr" lang="en"> <summary>Tests</summary> <ul class="wpt-tests-list"> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-declaration-51.html" title="css/css-variables/variable-declaration-51.html">variable-declaration-51.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-declaration-51.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-declaration-51.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-declaration-52.html" title="css/css-variables/variable-declaration-52.html">variable-declaration-52.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-declaration-52.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-declaration-52.html"><small>(source)</small></a> </ul> </details> <div class="example" id="example-beef67cd"> <a class="self-link" href="#example-beef67cd"></a> For example, given the following structure, these custom properties are <strong>not</strong> cyclic, and all define valid variables: <pre class="highlight"><c- p><</c-><c- f>one</c-><c- p>><</c-><c- f>two</c-><c- p>><</c-><c- f>three</c-> <c- p>/></</c-><c- f>two</c-><c- p>></</c-><c- f>one</c-><c- p>></c-> <c- p><</c-><c- f>style</c-><c- p>></c-> <c- f>one</c-> <c- p>{</c-> <c- g>--foo</c-><c- p>:</c-> <c- mi>10</c-><c- b>px</c-><c- p>;</c-> <c- p>}</c-> <c- f>two</c-> <c- p>{</c-> <c- g>--bar</c-><c- p>:</c-> calc<c- p>(</c-><c- nf>var</c-><c- p>(</c-><c- g>--foo</c-><c- p>)</c-> <c- o>+</c-> <c- mi>10</c-><c- b>px</c-><c- p>);</c-> <c- p>}</c-> <c- f>three</c-> <c- p>{</c-> <c- g>--foo</c-><c- p>:</c-> calc<c- p>(</c-><c- nf>var</c-><c- p>(</c-><c- g>--bar</c-><c- p>)</c-> <c- o>+</c-> <c- mi>10</c-><c- b>px</c-><c- p>);</c-> <c- p>}</c-> <c- p></</c-><c- f>style</c-><c- p>></c-> </pre> <p>The <one> element defines a value for <span class="css">--foo</span>. The <two> element inherits this value, and additionally assigns a value to <span class="css">--bar</span> using the <span class="css">foo</span> variable. Finally, the <three> element inherits the <span class="css">--bar</span> value <em>after</em> variable substitution (in other words, it sees the value <span class="css">calc(10px + 10px)</span>), and then redefines <span class="css">--foo</span> in terms of that value. Since the value it inherited for <span class="css">--bar</span> no longer contains a reference to the <span class="css">--foo</span> property defined on <one>, defining <span class="css">--foo</span> using the <span class="css">var(--bar)</span> variable is not cyclic, and actually defines a value that will eventually (when referenced as a variable in a normal property) resolve to <span class="css">30px</span>.</p> </div> <h2 class="heading settled" data-level="3" id="using-variables"><span class="secno">3. </span><span class="content"> Using Cascading Variables: the <a class="css" data-link-type="maybe" href="#funcdef-var" id="ref-for-funcdef-var①⑦">var()</a> notation</span><a class="self-link" href="#using-variables"></a></h2> <p>The value of a <a data-link-type="dfn" href="#custom-property" id="ref-for-custom-property②①">custom property</a> can be substituted into the value of another property with the <a class="css" data-link-type="maybe" href="#funcdef-var" id="ref-for-funcdef-var①⑧">var()</a> function. The syntax of <span class="css" id="ref-for-funcdef-var①⑨">var()</span> is:</p> <pre class="prod highlight"><dfn class="dfn-paneled" data-dfn-type="function" data-export id="funcdef-var"><c- nf>var</c-><c- p>()</c-></dfn> = <c- nf>var</c-><c- p>(</c-> <a class="production" data-link-type="type" href="#typedef-custom-property-name" id="ref-for-typedef-custom-property-name"><custom-property-name></a> <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-4/#comb-comma" id="ref-for-comb-comma"><c- p>,</c-></a> <a class="production" data-link-type="type" href="https://drafts.csswg.org/css-syntax-3/#typedef-declaration-value" id="ref-for-typedef-declaration-value②"><declaration-value></a><a data-link-type="grammar" href="https://drafts.csswg.org/css-values-4/#mult-opt" id="ref-for-mult-opt①">?</a> <c- p>)</c-> </pre> <p>The <a class="css" data-link-type="maybe" href="#funcdef-var" id="ref-for-funcdef-var②⓪">var()</a> function is an <a data-link-type="dfn" href="https://drafts.csswg.org/css-values-5/#arbitrary-substitution-function" id="ref-for-arbitrary-substitution-function①">arbitrary substitution function</a>.</p> <details class="wpt-tests-block" dir="ltr" lang="en"> <summary>Tests</summary> <ul class="wpt-tests-list"> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-reference-07.html" title="css/css-variables/variable-reference-07.html">variable-reference-07.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-reference-07.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-reference-07.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-reference-08.html" title="css/css-variables/variable-reference-08.html">variable-reference-08.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-reference-08.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-reference-08.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-reference-09.html" title="css/css-variables/variable-reference-09.html">variable-reference-09.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-reference-09.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-reference-09.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-reference-10.html" title="css/css-variables/variable-reference-10.html">variable-reference-10.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-reference-10.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-reference-10.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-reference-17.html" title="css/css-variables/variable-reference-17.html">variable-reference-17.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-reference-17.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-reference-17.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-reference-20.html" title="css/css-variables/variable-reference-20.html">variable-reference-20.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-reference-20.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-reference-20.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-reference-21.html" title="css/css-variables/variable-reference-21.html">variable-reference-21.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-reference-21.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-reference-21.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-reference-22.html" title="css/css-variables/variable-reference-22.html">variable-reference-22.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-reference-22.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-reference-22.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-reference-23.html" title="css/css-variables/variable-reference-23.html">variable-reference-23.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-reference-23.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-reference-23.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-reference-24.html" title="css/css-variables/variable-reference-24.html">variable-reference-24.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-reference-24.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-reference-24.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-reference-25.html" title="css/css-variables/variable-reference-25.html">variable-reference-25.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-reference-25.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-reference-25.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-reference-28.html" title="css/css-variables/variable-reference-28.html">variable-reference-28.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-reference-28.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-reference-28.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-reference-29.html" title="css/css-variables/variable-reference-29.html">variable-reference-29.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-reference-29.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-reference-29.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-reference-31.html" title="css/css-variables/variable-reference-31.html">variable-reference-31.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-reference-31.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-reference-31.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-reference-32.html" title="css/css-variables/variable-reference-32.html">variable-reference-32.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-reference-32.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-reference-32.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-reference-33.html" title="css/css-variables/variable-reference-33.html">variable-reference-33.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-reference-33.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-reference-33.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-reference-34.html" title="css/css-variables/variable-reference-34.html">variable-reference-34.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-reference-34.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-reference-34.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-reference-35.html" title="css/css-variables/variable-reference-35.html">variable-reference-35.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-reference-35.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-reference-35.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-reference.html" title="css/css-variables/variable-reference.html">variable-reference.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-reference.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-reference.html"><small>(source)</small></a> </ul> <p>@supports</p> <ul class="wpt-tests-list"> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-supports-01.html" title="css/css-variables/variable-supports-01.html">variable-supports-01.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-supports-01.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-supports-01.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-supports-02.html" title="css/css-variables/variable-supports-02.html">variable-supports-02.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-supports-02.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-supports-02.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-supports-03.html" title="css/css-variables/variable-supports-03.html">variable-supports-03.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-supports-03.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-supports-03.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-supports-04.html" title="css/css-variables/variable-supports-04.html">variable-supports-04.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-supports-04.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-supports-04.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-supports-05.html" title="css/css-variables/variable-supports-05.html">variable-supports-05.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-supports-05.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-supports-05.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-supports-06.html" title="css/css-variables/variable-supports-06.html">variable-supports-06.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-supports-06.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-supports-06.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-supports-07.html" title="css/css-variables/variable-supports-07.html">variable-supports-07.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-supports-07.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-supports-07.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-supports-08.html" title="css/css-variables/variable-supports-08.html">variable-supports-08.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-supports-08.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-supports-08.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-supports-09.html" title="css/css-variables/variable-supports-09.html">variable-supports-09.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-supports-09.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-supports-09.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-supports-10.html" title="css/css-variables/variable-supports-10.html">variable-supports-10.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-supports-10.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-supports-10.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-supports-11.html" title="css/css-variables/variable-supports-11.html">variable-supports-11.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-supports-11.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-supports-11.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-supports-12.html" title="css/css-variables/variable-supports-12.html">variable-supports-12.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-supports-12.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-supports-12.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-supports-13.html" title="css/css-variables/variable-supports-13.html">variable-supports-13.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-supports-13.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-supports-13.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-supports-14.html" title="css/css-variables/variable-supports-14.html">variable-supports-14.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-supports-14.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-supports-14.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-supports-15.html" title="css/css-variables/variable-supports-15.html">variable-supports-15.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-supports-15.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-supports-15.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-supports-16.html" title="css/css-variables/variable-supports-16.html">variable-supports-16.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-supports-16.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-supports-16.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-supports-17.html" title="css/css-variables/variable-supports-17.html">variable-supports-17.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-supports-17.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-supports-17.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-supports-18.html" title="css/css-variables/variable-supports-18.html">variable-supports-18.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-supports-18.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-supports-18.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-supports-19.html" title="css/css-variables/variable-supports-19.html">variable-supports-19.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-supports-19.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-supports-19.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-supports-20.html" title="css/css-variables/variable-supports-20.html">variable-supports-20.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-supports-20.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-supports-20.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-supports-21.html" title="css/css-variables/variable-supports-21.html">variable-supports-21.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-supports-21.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-supports-21.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-supports-22.html" title="css/css-variables/variable-supports-22.html">variable-supports-22.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-supports-22.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-supports-22.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-supports-23.html" title="css/css-variables/variable-supports-23.html">variable-supports-23.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-supports-23.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-supports-23.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-supports-24.html" title="css/css-variables/variable-supports-24.html">variable-supports-24.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-supports-24.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-supports-24.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-supports-25.html" title="css/css-variables/variable-supports-25.html">variable-supports-25.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-supports-25.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-supports-25.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-supports-26.html" title="css/css-variables/variable-supports-26.html">variable-supports-26.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-supports-26.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-supports-26.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-supports-27.html" title="css/css-variables/variable-supports-27.html">variable-supports-27.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-supports-27.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-supports-27.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-supports-28.html" title="css/css-variables/variable-supports-28.html">variable-supports-28.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-supports-28.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-supports-28.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-supports-29.html" title="css/css-variables/variable-supports-29.html">variable-supports-29.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-supports-29.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-supports-29.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-supports-30.html" title="css/css-variables/variable-supports-30.html">variable-supports-30.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-supports-30.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-supports-30.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-supports-31.html" title="css/css-variables/variable-supports-31.html">variable-supports-31.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-supports-31.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-supports-31.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-supports-32.html" title="css/css-variables/variable-supports-32.html">variable-supports-32.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-supports-32.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-supports-32.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-supports-33.html" title="css/css-variables/variable-supports-33.html">variable-supports-33.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-supports-33.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-supports-33.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-supports-34.html" title="css/css-variables/variable-supports-34.html">variable-supports-34.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-supports-34.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-supports-34.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-supports-35.html" title="css/css-variables/variable-supports-35.html">variable-supports-35.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-supports-35.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-supports-35.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-supports-36.html" title="css/css-variables/variable-supports-36.html">variable-supports-36.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-supports-36.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-supports-36.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-supports-37.html" title="css/css-variables/variable-supports-37.html">variable-supports-37.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-supports-37.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-supports-37.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-supports-38.html" title="css/css-variables/variable-supports-38.html">variable-supports-38.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-supports-38.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-supports-38.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-supports-39.html" title="css/css-variables/variable-supports-39.html">variable-supports-39.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-supports-39.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-supports-39.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-supports-40.html" title="css/css-variables/variable-supports-40.html">variable-supports-40.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-supports-40.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-supports-40.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-supports-41.html" title="css/css-variables/variable-supports-41.html">variable-supports-41.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-supports-41.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-supports-41.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-supports-42.html" title="css/css-variables/variable-supports-42.html">variable-supports-42.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-supports-42.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-supports-42.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-supports-43.html" title="css/css-variables/variable-supports-43.html">variable-supports-43.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-supports-43.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-supports-43.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-supports-44.html" title="css/css-variables/variable-supports-44.html">variable-supports-44.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-supports-44.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-supports-44.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-supports-45.html" title="css/css-variables/variable-supports-45.html">variable-supports-45.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-supports-45.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-supports-45.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-supports-46.html" title="css/css-variables/variable-supports-46.html">variable-supports-46.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-supports-46.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-supports-46.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-supports-47.html" title="css/css-variables/variable-supports-47.html">variable-supports-47.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-supports-47.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-supports-47.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-supports-48.html" title="css/css-variables/variable-supports-48.html">variable-supports-48.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-supports-48.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-supports-48.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-supports-49.html" title="css/css-variables/variable-supports-49.html">variable-supports-49.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-supports-49.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-supports-49.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-supports-50.html" title="css/css-variables/variable-supports-50.html">variable-supports-50.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-supports-50.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-supports-50.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-supports-51.html" title="css/css-variables/variable-supports-51.html">variable-supports-51.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-supports-51.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-supports-51.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-supports-52.html" title="css/css-variables/variable-supports-52.html">variable-supports-52.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-supports-52.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-supports-52.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-supports-53.html" title="css/css-variables/variable-supports-53.html">variable-supports-53.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-supports-53.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-supports-53.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-supports-54.html" title="css/css-variables/variable-supports-54.html">variable-supports-54.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-supports-54.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-supports-54.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-supports-55.html" title="css/css-variables/variable-supports-55.html">variable-supports-55.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-supports-55.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-supports-55.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-supports-56.html" title="css/css-variables/variable-supports-56.html">variable-supports-56.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-supports-56.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-supports-56.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-supports-57.html" title="css/css-variables/variable-supports-57.html">variable-supports-57.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-supports-57.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-supports-57.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-supports-58.html" title="css/css-variables/variable-supports-58.html">variable-supports-58.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-supports-58.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-supports-58.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-supports-59.html" title="css/css-variables/variable-supports-59.html">variable-supports-59.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-supports-59.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-supports-59.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-supports-60.html" title="css/css-variables/variable-supports-60.html">variable-supports-60.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-supports-60.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-supports-60.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-supports-61.html" title="css/css-variables/variable-supports-61.html">variable-supports-61.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-supports-61.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-supports-61.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-supports-62.html" title="css/css-variables/variable-supports-62.html">variable-supports-62.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-supports-62.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-supports-62.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-supports-63.html" title="css/css-variables/variable-supports-63.html">variable-supports-63.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-supports-63.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-supports-63.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-supports-64.html" title="css/css-variables/variable-supports-64.html">variable-supports-64.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-supports-64.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-supports-64.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-supports-65.html" title="css/css-variables/variable-supports-65.html">variable-supports-65.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-supports-65.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-supports-65.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-supports-66.html" title="css/css-variables/variable-supports-66.html">variable-supports-66.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-supports-66.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-supports-66.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-supports-67.html" title="css/css-variables/variable-supports-67.html">variable-supports-67.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-supports-67.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-supports-67.html"><small>(source)</small></a> </ul> <hr> </details> <p>The first argument to the function is the name of the <a data-link-type="dfn" href="#custom-property" id="ref-for-custom-property②②">custom property</a> to be substituted. The second argument to the function, if provided, is a fallback value, which is used as the substitution value when the value of the referenced <span id="ref-for-custom-property②③">custom property</span> is the <a data-link-type="dfn" href="#guaranteed-invalid-value" id="ref-for-guaranteed-invalid-value①⓪">guaranteed-invalid value</a>.</p> <details class="wpt-tests-block" dir="ltr" lang="en"> <summary>Tests</summary> <ul class="wpt-tests-list"> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-declaration-08.html" title="css/css-variables/variable-declaration-08.html">variable-declaration-08.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-declaration-08.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-declaration-08.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-declaration-09.html" title="css/css-variables/variable-declaration-09.html">variable-declaration-09.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-declaration-09.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-declaration-09.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-declaration-10.html" title="css/css-variables/variable-declaration-10.html">variable-declaration-10.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-declaration-10.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-declaration-10.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-declaration-11.html" title="css/css-variables/variable-declaration-11.html">variable-declaration-11.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-declaration-11.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-declaration-11.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-declaration-12.html" title="css/css-variables/variable-declaration-12.html">variable-declaration-12.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-declaration-12.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-declaration-12.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-declaration-13.html" title="css/css-variables/variable-declaration-13.html">variable-declaration-13.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-declaration-13.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-declaration-13.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-declaration-22.html" title="css/css-variables/variable-declaration-22.html">variable-declaration-22.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-declaration-22.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-declaration-22.html"><small>(source)</small></a> </ul> </details> <p>In an exception to the usual <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-4/#comb-comma" id="ref-for-comb-comma①">comma elision rules</a>, which require commas to be omitted when they’re not separating values, a bare comma, with nothing following it, must be treated as valid in <a class="css" data-link-type="maybe" href="#funcdef-var" id="ref-for-funcdef-var②①">var()</a>, indicating an empty fallback value.</p> <details class="wpt-tests-block" dir="ltr" lang="en"> <summary>Tests</summary> <ul class="wpt-tests-list"> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-declaration-07.html" title="css/css-variables/variable-declaration-07.html">variable-declaration-07.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-declaration-07.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-declaration-07.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-declaration-37.html" title="css/css-variables/variable-declaration-37.html">variable-declaration-37.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-declaration-37.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-declaration-37.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-reference-06.html" title="css/css-variables/variable-reference-06.html">variable-reference-06.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-reference-06.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-reference-06.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-reference-11.html" title="css/css-variables/variable-reference-11.html">variable-reference-11.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-reference-11.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-reference-11.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-reference-26.html" title="css/css-variables/variable-reference-26.html">variable-reference-26.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-reference-26.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-reference-26.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-reference-27.html" title="css/css-variables/variable-reference-27.html">variable-reference-27.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-reference-27.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-reference-27.html"><small>(source)</small></a> </ul> </details> <p class="note" role="note"><span class="marker">Note:</span> That is, <span class="css">var(--a,)</span> is a valid function, specifying that if the <span class="css">--a</span> custom property is invalid or missing, the <a class="css" data-link-type="maybe" href="#funcdef-var" id="ref-for-funcdef-var②②">var()</a> should be replaced with nothing.</p> <p class="note" role="note"><span class="marker">Note:</span> The syntax of the fallback, like that of <a data-link-type="dfn" href="#custom-property" id="ref-for-custom-property②④">custom properties</a>, allows commas. For example, <span class="css">var(--foo, red, blue)</span> defines a fallback of <span class="css">red, blue</span>; that is, anything between the first comma and the end of the function is considered a fallback value.</p> <div class="example" id="example-abd63bac"> <a class="self-link" href="#example-abd63bac"></a> The fallback value allows for some types of defensive coding. For example, an author may create a component intended to be included in a larger application, and use variables to style it so that it’s easy for the author of the larger application to theme the component to match the rest of the app. <p>Without fallback, the app author must supply a value for every variable that your component uses. With fallback, the component author can supply defaults, so the app author only needs to supply values for the variables they wish to override.</p> <pre class="highlight"><c- c>/* In the component’s style: */</c-> .component .header <c- p>{</c-> <c- k>color</c-><c- p>:</c-> <c- nf>var</c-><c- p>(</c->--header-color<c- p>,</c-> blue<c- p>);</c-> <c- p>}</c-> .component .text <c- p>{</c-> <c- k>color</c-><c- p>:</c-> <c- nf>var</c-><c- p>(</c->--text-color<c- p>,</c-> black<c- p>);</c-> <c- p>}</c-> <c- c>/* In the larger application’s style: */</c-> .component <c- p>{</c-> <c- k>--text-color</c-><c- p>:</c-> #080<c- p>;</c-> <c- c>/* header-color isn’t set,</c-> <c- c> and so remains blue,</c-> <c- c> the fallback value */</c-> <c- p>}</c-> </pre> </div> <div class="algorithm" data-algorithm="resolve a var()"> To <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="resolve-a-var-function"><a data-link-type="dfn" href="https://drafts.csswg.org/css-values-5/#resolve-an-arbitrary-substitution-function" id="ref-for-resolve-an-arbitrary-substitution-function">resolve a var() function</a></dfn>: <ol> <li data-md> <p>Let <var>result</var> be the value of the <a data-link-type="dfn" href="#custom-property" id="ref-for-custom-property②⑤">custom property</a> named by the function’s first argument, on the element the function’s property is being applied to.</p> <li data-md> <p>Let <var>fallback</var> be the value of the function’s second argument, defaulting to the <a data-link-type="dfn" href="#guaranteed-invalid-value" id="ref-for-guaranteed-invalid-value①①">guaranteed-invalid value</a> if it doesn’t have a second argument.</p> <li data-md> <p>If the <a data-link-type="dfn" href="#custom-property" id="ref-for-custom-property②⑥">custom property</a> named by the <a class="css" data-link-type="maybe" href="#funcdef-var" id="ref-for-funcdef-var②③">var()</a>’s first argument is <a data-link-type="dfn" href="#animation-tainted" id="ref-for-animation-tainted③">animation-tainted</a>, and the <span class="css" id="ref-for-funcdef-var②④">var()</span> is being used in a property that is <a data-link-type="dfn" href="https://drafts.csswg.org/web-animations-1/#not-animatable" id="ref-for-not-animatable">not animatable</a>, set <var>result</var> to the <a data-link-type="dfn" href="#guaranteed-invalid-value" id="ref-for-guaranteed-invalid-value①②">guaranteed-invalid value</a>.</p> <li data-md> <p>Return <var>result</var> and <var>fallback</var>.</p> </ol> </div> <h2 class="heading settled" data-level="4" id="apis"><span class="secno">4. </span><span class="content"> APIs</span><a class="self-link" href="#apis"></a></h2> <p>All <a data-link-type="dfn" href="#custom-property" id="ref-for-custom-property②⑦">custom property</a> <a data-link-type="dfn" href="https://drafts.csswg.org/cssom-1/#cssstyledeclaration-declarations" id="ref-for-cssstyledeclaration-declarations">declarations</a> have the <a data-link-type="dfn" href="https://drafts.csswg.org/cssom-1/#css-declaration-case-sensitive-flag" id="ref-for-css-declaration-case-sensitive-flag">case-sensitive flag</a> set.</p> <details class="wpt-tests-block" dir="ltr" lang="en"> <summary>Tests</summary> <ul class="wpt-tests-list"> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-definition.html" title="css/css-variables/variable-definition.html">variable-definition.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-definition.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-definition.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-invalidation.html" title="css/css-variables/variable-invalidation.html">variable-invalidation.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-invalidation.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-invalidation.html"><small>(source)</small></a> </ul> </details> <p class="note" role="note"><span class="marker">Note:</span> Custom properties do not appear on a CSSStyleDeclaration object in camel-cased form, because their names may have both upper and lowercase letters which indicate distinct custom properties. The sort of text transformation that automatic camel-casing performs is incompatible with this. They can still be accessed by their proper name via <a class="idl-code" data-link-type="method" href="https://drafts.csswg.org/cssom-1/#dom-cssstyledeclaration-getpropertyvalue" id="ref-for-dom-cssstyledeclaration-getpropertyvalue">getPropertyValue()</a>/etc.</p> <h3 class="heading settled" data-level="4.1" id="serializing-custom-props"><span class="secno">4.1. </span><span class="content"> Serializing Custom Properties</span><a class="self-link" href="#serializing-custom-props"></a></h3> <p>Custom property names must be serialized as the exact code point sequence provided by the author, including not altering the case.</p> <p class="note" role="note"><span class="marker">Note:</span> For non-custom properties, property names are restricted to the ASCII range and are <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" id="ref-for-ascii-case-insensitive②">ASCII case-insensitive</a>, so implementations typically serialize the name lowercased.</p> <p>Specified values of <a data-link-type="dfn" href="#custom-property" id="ref-for-custom-property②⑧">custom properties</a> must be serialized <em>exactly as specified by the author</em> (with one exception, below). Simplifications that might occur in other properties, such as dropping comments, normalizing whitespace, reserializing numeric tokens from their value, etc., must not occur.</p> <p>Computed values of <a data-link-type="dfn" href="#custom-property" id="ref-for-custom-property②⑨">custom properties</a> must similarly be serialized <em>exactly as specified by the author</em> (with the same one exception, below), save for the replacement of any <a class="css" data-link-type="maybe" href="#funcdef-var" id="ref-for-funcdef-var②⑤">var()</a> functions.</p> <p>The one exception to serialization being precisely as specified in the source file is that an <em>empty</em> custom property (such as <span class="css">--foo:;</span>) must serialize with a single space as its value.</p> <details class="wpt-tests-block" dir="ltr" lang="en"> <summary>Tests</summary> <ul class="wpt-tests-list"> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-reference-shorthands-cssom.html" title="css/css-variables/variable-reference-shorthands-cssom.html">variable-reference-shorthands-cssom.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-reference-shorthands-cssom.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-reference-shorthands-cssom.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-reference-variable.html" title="css/css-variables/variable-reference-variable.html">variable-reference-variable.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-reference-variable.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-reference-variable.html"><small>(source)</small></a> </ul> </details> <div class="example" id="example-55f61182"> <a class="self-link" href="#example-55f61182"></a> For example, given the following properties: <pre class="highlight"><c- k>--y</c-><c- p>:</c-> <c- c>/* baz */</c-><c- p>;</c-> <c- k>--x</c-><c- p>:</c-> <c- c>/* foo */</c-> <c- nf>var</c-><c- p>(</c->--y<c- p>)</c-> <c- c>/* bar */</c-><c- p>;</c-> </pre> <p>the serialization of the specified value of <span class="css">--x</span> must be <code class="highlight"><c- s>"/* foo */ var(--y) /* bar */"</c-></code>, while the serialization of the computed value of <span class="css">--x</span> must be <code class="highlight"><c- s>"/* foo */ /* baz */ /* bar */"</c-></code>.</p> <p>(Note that the leading whitespace on the value is automatically trimmed by the CSS parser; it’s not preserved here.)</p> </div> <div class="note" role="note"> This "exactly as specified" requirement exists because authors sometimes store non-CSS information in custom properties, and "normalizing" this information can change it in ways that break author code. <p>For example, storing a UUID in a custom property, like <a class="css" data-link-type="propdesc">--uuid: 12345678-12e3-8d9b-a456-426614174000</a>, requires the UUID to be echoed back out as written when it’s accessed by script.</p> <p>This value is technically parsed by CSS as a series of adjacent numbers and dimensions. In particular, the segment "-12e3" parses as a number, equal to -12000. Reserializing it in that form, as required by CSSOM in other contexts, would fatally break the author’s use of the value.</p> </div> <div class="note" role="note"> The requirement to serialize an empty custom property as a string with a single space in it instead is due to compatibility with the existing CSSOM API. <code class="idl"><a data-link-type="idl" href="https://drafts.csswg.org/cssom-1/#dom-cssstyledeclaration-setproperty" id="ref-for-dom-cssstyledeclaration-setproperty">setProperty()</a></code> specifies that if the passed value is an empty string it instead acts as <code class="idl"><a data-link-type="idl" href="https://drafts.csswg.org/cssom-1/#dom-cssstyledeclaration-removeproperty" id="ref-for-dom-cssstyledeclaration-removeproperty">removeProperty()</a></code>. <p>This is a frankly weird behavior, and not something we would do in new APIs. But we can’t change the past, and letting empty properties accurately serialize as the empty string would mean that round-tripping a custom property value, or reading a property on one element and setting a property on another element to the same value, wouldn’t work as intended. Using a single space preserves the author-intended behavior as much as possible, while having the smallest chance of accidentally breaking things, since authors working with custom property values in JS are probably calling <code class="idl"><a data-link-type="idl" href="https://tc39.es/ecma262/multipage/text-processing.html#sec-string.prototype.trim" id="ref-for-sec-string.prototype.trim">trim()</a></code> on the values anyway.</p> </div> <h2 class="heading settled" data-level="5" id="changes"><span class="secno">5. </span><span class="content"> Changes</span><a class="self-link" href="#changes"></a></h2> <h3 class="heading settled" data-level="5.1" id="changes-20220616"><span class="secno">5.1. </span><span class="content"> Changes Since the 16 June 2022 CR Snapshot</span><a class="self-link" href="#changes-20220616"></a></h3> <ul> <li data-md> <p>Clarified that the comment-insertion can happen with 0+ comments between the original tokens, not just exactly 1.</p> <li data-md> <p>Clarified the transition behavior of custom properties, in a note</p> </ul> <h3 class="heading settled" data-level="5.2" id="changes-20211111"><span class="secno">5.2. </span><span class="content"> Changes Since the 11 November 2021 CR Draft</span><a class="self-link" href="#changes-20211111"></a></h3> <ul> <li data-md> <p>Clarified that custom properties apply all pseudo-elements (including those with restricted property lists)</p> <li data-md> <p>Added example to illustrate issues with combining characters, ligatures, etc</p> <li data-md> <p>Strengthened wording around similar-appearing variable names that use distinct codepoint sequences</p> <li data-md> <p>Clarified an example by using more visually distinct languages as examples (English and Greek)</p> <li data-md> <p>Split Security and Privacy into separate sections</p> </ul> <h3 class="heading settled" data-level="5.3" id="changes-20151203"><span class="secno">5.3. </span><span class="content"> Changes Since the 03 December 2015 CR</span><a class="self-link" href="#changes-20151203"></a></h3> <ul> <li data-md> <p>Now that <a data-link-type="biblio" href="#biblio-css-syntax-3" title="CSS Syntax Module Level 3">[css-syntax-3]</a> auto-trims whitespace from declaration values, made <a class="production css" data-link-type="type" href="https://drafts.csswg.org/css-syntax-3/#typedef-declaration-value" id="ref-for-typedef-declaration-value③"><declaration-value></a> optional in the custom property grammar, so that empty variables are still allowed. (<a href="https://github.com/w3c/csswg-drafts/issues/774#issuecomment-434571254">Issue 774</a>)</p> <li data-md> <p>Similarly, made empty fallbacks valid in <a class="css" data-link-type="maybe" href="#funcdef-var" id="ref-for-funcdef-var②⑥">var()</a>.</p> <li data-md> <p>The <span class="css">--</span> property is reserved for future use by CSS.</p> <li data-md> <p>Added concept of "animation-tainted", to prevent non-animatable properties from using a variable to smuggle in some animatability.</p> <li data-md> <p>Defined the <a data-link-type="dfn" href="#guaranteed-invalid-value" id="ref-for-guaranteed-invalid-value①③">guaranteed-invalid value</a> to make the initial value of custom properties and the result of cycles or substitution failure more straightforward, and allow failure to propagate thru substitutions until finally intercepted by a fallback.</p> <li data-md> <p>Defined that cycles trigger <a data-link-type="dfn" href="https://drafts.csswg.org/css-values-5/#invalid-at-computed-value-time" id="ref-for-invalid-at-computed-value-time④">invalid at computed-value time</a> behavior.</p> <li data-md> <p>Allowed variables to resolve to a CSS-wide keyword (only possible by providing it as a fallback).</p> <li data-md> <p>Clarified that <a data-link-type="dfn" href="https://drafts.css-houdini.org/css-properties-values-api-1/#registered-custom-property" id="ref-for-registered-custom-property①">registered custom properties</a> act like non-custom properties when they’re <a data-link-type="dfn" href="https://drafts.csswg.org/css-values-5/#invalid-at-computed-value-time" id="ref-for-invalid-at-computed-value-time⑤">invalid at computed-value time</a>.</p> <li data-md> <p>Made longhands with <a class="css" data-link-type="maybe" href="#funcdef-var" id="ref-for-funcdef-var②⑦">var()</a>s also trigger their shorthands to be unserializable, like longhands with pending-substitution values already did.</p> <li data-md> <p>Required UAs to defend against exponential substitution attacks.</p> <li data-md> <p>Defined how to serialize the <em>values</em> of custom properties (previously, only the property name’s serialization was specified).</p> </ul> <h3 class="heading settled" data-level="5.4" id="changes-20140506"><span class="secno">5.4. </span><span class="content"> Changes since the May 6 2014 Last Call Working Draft</span><a class="self-link" href="#changes-20140506"></a></h3> <ul> <li data-md> <p>Serialization of longhands when shorthand uses a variable was defined.</p> <li data-md> <p>Link to DOM’s definition of "case-sensitive".</p> <li data-md> <p>Added example of using variables with <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/selectors-4/#lang-pseudo" id="ref-for-lang-pseudo">:lang()</a> to do simple i18n.</p> <li data-md> <p>Clarified that usage of <a class="css" data-link-type="maybe" href="#funcdef-var" id="ref-for-funcdef-var②⑧">var()</a> in a custom property must be valid per the <span class="css" id="ref-for-funcdef-var②⑨">var()</span> grammar.</p> </ul> <h2 class="heading settled" data-level="6" id="acks"><span class="secno">6. </span><span class="content"> Acknowledgments</span><a class="self-link" href="#acks"></a></h2> <p>Many thanks to several people in the CSS Working Group for keeping the dream of variables alive over the years, particularly Daniel Glazman and David Hyatt. Thanks to multiple people on the mailing list for helping contribute to the development of this incarnation of variables, particularly Brian Kardell, David Baron, François Remy, Roland Steiner, and Shane Stephens.</p> <h2 class="heading settled" data-level="7" id="privacy"><span class="secno">7. </span><span class="content">Privacy Considerations</span><a class="self-link" href="#privacy"></a></h2> <p>This specification defines a purely author-level mechanism for passing styling information around within a page they control. As such, there are no new privacy considerations.</p> <h2 class="heading settled" data-level="8" id="security"><span class="secno">8. </span><span class="content">Security Considerations</span><a class="self-link" href="#security"></a></h2> <p><a href="https://drafts.csswg.org/css-values-5/#long-substitution"><cite>CSS Values 5</cite> § Safely Handling Overly-Long Substitution</a> calls out a long-standing Denial-of-Service attack that can be mounted against "macro-expansion"-like mechanisms, such as the <a class="css" data-link-type="maybe" href="#funcdef-var" id="ref-for-funcdef-var③⓪">var()</a> function, and mandates a defense against that attack.</p> <details class="wpt-tests-block" data-var-ignore dir="ltr" lang="en"> <summary>Tests</summary> <ul class="wpt-tests-list"> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/revert-in-fallback.html" title="css/css-variables/revert-in-fallback.html">revert-in-fallback.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/revert-in-fallback.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/revert-in-fallback.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/revert-layer-in-fallback.html" title="css/css-variables/revert-layer-in-fallback.html">revert-layer-in-fallback.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/revert-layer-in-fallback.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/revert-layer-in-fallback.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variables-animation-math-functions.html" title="css/css-variables/variables-animation-math-functions.html">variables-animation-math-functions.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variables-animation-math-functions.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variables-animation-math-functions.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-recalc-with-initial.html" title="css/css-variables/variable-recalc-with-initial.html">variable-recalc-with-initial.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-recalc-with-initial.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-recalc-with-initial.html"><small>(source)</small></a> </ul> </details> <p> <details class="wpt-tests-block" dir="ltr" lang="en"> <summary>Tests</summary> <ul class="wpt-tests-list"> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/url-syntax-crash.html" title="css/css-variables/url-syntax-crash.html">url-syntax-crash.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/url-syntax-crash.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/url-syntax-crash.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/whitespace-in-fallback-crash.html" title="css/css-variables/whitespace-in-fallback-crash.html">whitespace-in-fallback-crash.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/whitespace-in-fallback-crash.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/whitespace-in-fallback-crash.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-declaration-01.html" title="css/css-variables/variable-declaration-01.html">variable-declaration-01.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-declaration-01.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-declaration-01.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-declaration-02.html" title="css/css-variables/variable-declaration-02.html">variable-declaration-02.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-declaration-02.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-declaration-02.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-declaration-03.html" title="css/css-variables/variable-declaration-03.html">variable-declaration-03.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-declaration-03.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-declaration-03.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-declaration-04.html" title="css/css-variables/variable-declaration-04.html">variable-declaration-04.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-declaration-04.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-declaration-04.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-declaration-05.html" title="css/css-variables/variable-declaration-05.html">variable-declaration-05.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-declaration-05.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-declaration-05.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-declaration-14.html" title="css/css-variables/variable-declaration-14.html">variable-declaration-14.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-declaration-14.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-declaration-14.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-declaration-16.html" title="css/css-variables/variable-declaration-16.html">variable-declaration-16.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-declaration-16.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-declaration-16.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-declaration-17.html" title="css/css-variables/variable-declaration-17.html">variable-declaration-17.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-declaration-17.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-declaration-17.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-declaration-18.html" title="css/css-variables/variable-declaration-18.html">variable-declaration-18.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-declaration-18.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-declaration-18.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-declaration-19.html" title="css/css-variables/variable-declaration-19.html">variable-declaration-19.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-declaration-19.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-declaration-19.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-declaration-21.html" title="css/css-variables/variable-declaration-21.html">variable-declaration-21.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-declaration-21.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-declaration-21.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-declaration-53.html" title="css/css-variables/variable-declaration-53.html">variable-declaration-53.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-declaration-53.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-declaration-53.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-declaration-54.html" title="css/css-variables/variable-declaration-54.html">variable-declaration-54.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-declaration-54.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-declaration-54.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-declaration-55.html" title="css/css-variables/variable-declaration-55.html">variable-declaration-55.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-declaration-55.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-declaration-55.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-external-font-face-01.html" title="css/css-variables/variable-external-font-face-01.html">variable-external-font-face-01.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-external-font-face-01.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-external-font-face-01.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-font-face-01.html" title="css/css-variables/variable-font-face-01.html">variable-font-face-01.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-font-face-01.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-font-face-01.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-font-face-02.html" title="css/css-variables/variable-font-face-02.html">variable-font-face-02.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-font-face-02.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-font-face-02.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-generated-content-dynamic-001.html" title="css/css-variables/variable-generated-content-dynamic-001.html">variable-generated-content-dynamic-001.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-generated-content-dynamic-001.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-generated-content-dynamic-001.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-invalid-recovery.html" title="css/css-variables/variable-invalid-recovery.html">variable-invalid-recovery.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-invalid-recovery.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-invalid-recovery.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-reference-01.html" title="css/css-variables/variable-reference-01.html">variable-reference-01.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-reference-01.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-reference-01.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-reference-02.html" title="css/css-variables/variable-reference-02.html">variable-reference-02.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-reference-02.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-reference-02.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-reference-03.html" title="css/css-variables/variable-reference-03.html">variable-reference-03.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-reference-03.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-reference-03.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-reference-04.html" title="css/css-variables/variable-reference-04.html">variable-reference-04.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-reference-04.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-reference-04.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-reference-05.html" title="css/css-variables/variable-reference-05.html">variable-reference-05.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-reference-05.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-reference-05.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-reference-12.html" title="css/css-variables/variable-reference-12.html">variable-reference-12.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-reference-12.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-reference-12.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-reference-15.html" title="css/css-variables/variable-reference-15.html">variable-reference-15.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-reference-15.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-reference-15.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-reference-16.html" title="css/css-variables/variable-reference-16.html">variable-reference-16.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-reference-16.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-reference-16.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-reference-18.html" title="css/css-variables/variable-reference-18.html">variable-reference-18.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-reference-18.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-reference-18.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-reference-19.html" title="css/css-variables/variable-reference-19.html">variable-reference-19.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-reference-19.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-reference-19.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-reference-30.html" title="css/css-variables/variable-reference-30.html">variable-reference-30.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-reference-30.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-reference-30.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-reference-36.html" title="css/css-variables/variable-reference-36.html">variable-reference-36.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-reference-36.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-reference-36.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-reference-37.html" title="css/css-variables/variable-reference-37.html">variable-reference-37.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-reference-37.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-reference-37.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-reference-38.html" title="css/css-variables/variable-reference-38.html">variable-reference-38.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-reference-38.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-reference-38.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-reference-40.html" title="css/css-variables/variable-reference-40.html">variable-reference-40.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-reference-40.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-reference-40.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-reference-without-whitespace.html" title="css/css-variables/variable-reference-without-whitespace.html">variable-reference-without-whitespace.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-reference-without-whitespace.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-reference-without-whitespace.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/vars-background-shorthand-001.html" title="css/css-variables/vars-background-shorthand-001.html">vars-background-shorthand-001.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/vars-background-shorthand-001.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/vars-background-shorthand-001.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/vars-font-shorthand-001.html" title="css/css-variables/vars-font-shorthand-001.html">vars-font-shorthand-001.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/vars-font-shorthand-001.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/vars-font-shorthand-001.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/wide-keyword-fallback-001.html" title="css/css-variables/wide-keyword-fallback-001.html">wide-keyword-fallback-001.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/wide-keyword-fallback-001.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/wide-keyword-fallback-001.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/wide-keyword-fallback-002.html" title="css/css-variables/wide-keyword-fallback-002.html">wide-keyword-fallback-002.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/wide-keyword-fallback-002.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/wide-keyword-fallback-002.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/css-variable-change-style-001.html" title="css/css-variables/css-variable-change-style-001.html">css-variable-change-style-001.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/css-variable-change-style-001.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/css-variable-change-style-001.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/css-variable-change-style-002.html" title="css/css-variables/css-variable-change-style-002.html">css-variable-change-style-002.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/css-variable-change-style-002.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/css-variable-change-style-002.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/var-parsing.html" title="css/css-variables/var-parsing.html">var-parsing.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/var-parsing.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/var-parsing.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-definition-border-shorthand-serialize.html" title="css/css-variables/variable-definition-border-shorthand-serialize.html">variable-definition-border-shorthand-serialize.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-definition-border-shorthand-serialize.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-definition-border-shorthand-serialize.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-exponential-blowup.html" title="css/css-variables/variable-exponential-blowup.html">variable-exponential-blowup.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-exponential-blowup.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-exponential-blowup.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-presentation-attribute.html" title="css/css-variables/variable-presentation-attribute.html">variable-presentation-attribute.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-presentation-attribute.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-presentation-attribute.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-reference-cssom.html" title="css/css-variables/variable-reference-cssom.html">variable-reference-cssom.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-reference-cssom.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-reference-cssom.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-reference-refresh.html" title="css/css-variables/variable-reference-refresh.html">variable-reference-refresh.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-reference-refresh.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-reference-refresh.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-substitution-background-properties.html" title="css/css-variables/variable-substitution-background-properties.html">variable-substitution-background-properties.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-substitution-background-properties.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-substitution-background-properties.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-substitution-basic.html" title="css/css-variables/variable-substitution-basic.html">variable-substitution-basic.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-substitution-basic.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-substitution-basic.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-substitution-filters.html" title="css/css-variables/variable-substitution-filters.html">variable-substitution-filters.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-substitution-filters.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-substitution-filters.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-substitution-replaced-size.html" title="css/css-variables/variable-substitution-replaced-size.html">variable-substitution-replaced-size.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-substitution-replaced-size.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-substitution-replaced-size.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-substitution-shadow-properties.html" title="css/css-variables/variable-substitution-shadow-properties.html">variable-substitution-shadow-properties.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-substitution-shadow-properties.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-substitution-shadow-properties.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-substitution-shorthands.html" title="css/css-variables/variable-substitution-shorthands.html">variable-substitution-shorthands.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-substitution-shorthands.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-substitution-shorthands.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-substitution-variable-declaration.html" title="css/css-variables/variable-substitution-variable-declaration.html">variable-substitution-variable-declaration.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-substitution-variable-declaration.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-substitution-variable-declaration.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-transitions-transition-property-all-before-value.html" title="css/css-variables/variable-transitions-transition-property-all-before-value.html">variable-transitions-transition-property-all-before-value.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-transitions-transition-property-all-before-value.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-transitions-transition-property-all-before-value.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variable-transitions-value-before-transition-property-all.html" title="css/css-variables/variable-transitions-value-before-transition-property-all.html">variable-transitions-value-before-transition-property-all.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variable-transitions-value-before-transition-property-all.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variable-transitions-value-before-transition-property-all.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/variables-substitute-guaranteed-invalid.html" title="css/css-variables/variables-substitute-guaranteed-invalid.html">variables-substitute-guaranteed-invalid.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/variables-substitute-guaranteed-invalid.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/variables-substitute-guaranteed-invalid.html"><small>(source)</small></a> <li class="wpt-test"><a class="wpt-name" href="https://wpt.fyi/results/css/css-variables/vars-border-shorthand-serialize.html" title="css/css-variables/vars-border-shorthand-serialize.html">vars-border-shorthand-serialize.html</a> <a class="wpt-live" href="http://wpt.live/css/css-variables/vars-border-shorthand-serialize.html"><small>(live test)</small></a> <a class="wpt-source" href="https://github.com/web-platform-tests/wpt/blob/master/css/css-variables/vars-border-shorthand-serialize.html"><small>(source)</small></a> </ul> </details> </p> </main> <h2 class="no-ref no-num heading settled" id="w3c-conformance"><span class="content"> Conformance</span><a class="self-link" href="#w3c-conformance"></a></h2> <h3 class="no-ref heading settled" id="w3c-conventions"><span class="content"> Document conventions</span><a class="self-link" href="#w3c-conventions"></a></h3> <p>Conformance requirements are expressed with a combination of descriptive assertions and RFC 2119 terminology. The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in the normative parts of this document are to be interpreted as described in RFC 2119. However, for readability, these words do not appear in all uppercase letters in this specification. </p> <p>All of the text of this specification is normative except sections explicitly marked as non-normative, examples, and notes. <a data-link-type="biblio" href="#biblio-rfc2119" title="Key words for use in RFCs to Indicate Requirement Levels">[RFC2119]</a></p> <p>Examples in this specification are introduced with the words “for example” or are set apart from the normative text with <code class="highlight">class=<c- s>"example"</c-></code>, like this: </p> <div class="example" id="w3c-example"> <a class="self-link" href="#w3c-example"></a> <p>This is an example of an informative example.</p> </div> <p>Informative notes begin with the word “Note” and are set apart from the normative text with <code class="highlight">class=<c- s>"note"</c-></code>, like this: </p> <p class="note" role="note">Note, this is an informative note.</p> <p>Advisements are normative sections styled to evoke special attention and are set apart from other normative text with <code class="highlight"><strong class=<c- s>"advisement"</c->></code>, like this: <strong class="advisement"> UAs MUST provide an accessible alternative. </strong></p> <details class="wpt-tests-block" dir="ltr" lang="en" open> <summary>Tests</summary> <p>Tests relating to the content of this specification may be documented in “Tests” blocks like this one. Any such block is non-normative.</p> <ul class="wpt-tests-list"></ul> <hr> </details> <h3 class="no-ref heading settled" id="w3c-conformance-classes"><span class="content"> Conformance classes</span><a class="self-link" href="#w3c-conformance-classes"></a></h3> <p>Conformance to this specification is defined for three conformance classes: </p> <dl> <dt>style sheet <dd>A <a href="http://www.w3.org/TR/CSS21/conform.html#style-sheet">CSS style sheet</a>. <dt>renderer <dd>A <a href="http://www.w3.org/TR/CSS21/conform.html#user-agent">UA</a> that interprets the semantics of a style sheet and renders documents that use them. <dt>authoring tool <dd>A <a href="http://www.w3.org/TR/CSS21/conform.html#user-agent">UA</a> that writes a style sheet. </dl> <p>A style sheet is conformant to this specification if all of its statements that use syntax defined in this module are valid according to the generic CSS grammar and the individual grammars of each feature defined in this module. </p> <p>A renderer is conformant to this specification if, in addition to interpreting the style sheet as defined by the appropriate specifications, it supports all the features defined by this specification by parsing them correctly and rendering the document accordingly. However, the inability of a UA to correctly render a document due to limitations of the device does not make the UA non-conformant. (For example, a UA is not required to render color on a monochrome monitor.) </p> <p>An authoring tool is conformant to this specification if it writes style sheets that are syntactically correct according to the generic CSS grammar and the individual grammars of each feature in this module, and meet all other conformance requirements of style sheets as described in this module. </p> <h3 class="no-ref heading settled" id="w3c-partial"><span class="content"> Partial implementations</span><a class="self-link" href="#w3c-partial"></a></h3> <p>So that authors can exploit the forward-compatible parsing rules to assign fallback values, CSS renderers <strong>must</strong> treat as invalid (and <a href="http://www.w3.org/TR/CSS21/conform.html#ignore">ignore as appropriate</a>) any at-rules, properties, property values, keywords, and other syntactic constructs for which they have no usable level of support. In particular, user agents <strong>must not</strong> selectively ignore unsupported component values and honor supported values in a single multi-value property declaration: if any value is considered invalid (as unsupported values must be), CSS requires that the entire declaration be ignored.</p> <h4 class="heading settled" id="w3c-conform-future-proofing"><span class="content"> Implementations of Unstable and Proprietary Features</span><a class="self-link" href="#w3c-conform-future-proofing"></a></h4> <p>To avoid clashes with future stable CSS features, the CSSWG recommends <a href="http://www.w3.org/TR/CSS/#future-proofing">following best practices</a> for the implementation of <a href="http://www.w3.org/TR/CSS/#unstable">unstable</a> features and <a href="http://www.w3.org/TR/CSS/#proprietary-extension">proprietary extensions</a> to CSS. </p> <h3 class="no-ref heading settled" id="w3c-testing"><span class="content"> Non-experimental implementations</span><a class="self-link" href="#w3c-testing"></a></h3> <p>Once a specification reaches the Candidate Recommendation stage, non-experimental implementations are possible, and implementors should release an unprefixed implementation of any CR-level feature they can demonstrate to be correctly implemented according to spec. </p> <p>To establish and maintain the interoperability of CSS across implementations, the CSS Working Group requests that non-experimental CSS renderers submit an implementation report (and, if necessary, the testcases used for that implementation report) to the W3C before releasing an unprefixed implementation of any CSS features. Testcases submitted to W3C are subject to review and correction by the CSS Working Group. </p> <p>Further information on submitting testcases and implementation reports can be found from on the CSS Working Group’s website at <a href="http://www.w3.org/Style/CSS/Test/">http://www.w3.org/Style/CSS/Test/</a>. Questions should be directed to the <a href="http://lists.w3.org/Archives/Public/public-css-testsuite">public-css-testsuite@w3.org</a> mailing list.</p> <script src="https://www.w3.org/scripts/TR/2021/fixup.js"></script> <h2 class="no-num no-ref heading settled" id="index"><span class="content">Index</span><a class="self-link" href="#index"></a></h2> <h3 class="no-num no-ref heading settled" id="index-defined-here"><span class="content">Terms defined by this specification</span><a class="self-link" href="#index-defined-here"></a></h3> <ul class="index"> <li><a href="#propdef-">--*</a><span>, in § 2</span> <li><a href="#animation-tainted">animation-tainted</a><span>, in § 2</span> <li><a href="#custom-property">custom property</a><span>, in § 2</span> <li><a href="#typedef-custom-property-name"><custom-property-name></a><span>, in § 2</span> <li><a href="#guaranteed-invalid-value">guaranteed-invalid value</a><span>, in § 2.2</span> <li><a href="#resolve-a-var-function">resolve a var() function</a><span>, in § 3</span> <li><a href="#funcdef-var">var()</a><span>, in § 3</span> </ul> <h3 class="no-num no-ref heading settled" id="index-defined-elsewhere"><span class="content">Terms defined by reference</span><a class="self-link" href="#index-defined-elsewhere"></a></h3> <ul class="index"> <li> <a data-link-type="biblio">[CSS-ANIMATIONS-1]</a> defines the following terms: <ul> <li><span class="dfn-paneled" id="fa19c68e">@keyframes</span> </ul> <li> <a data-link-type="biblio">[CSS-BACKGROUNDS-3]</a> defines the following terms: <ul> <li><span class="dfn-paneled" id="f5eca8c9">background</span> <li><span class="dfn-paneled" id="11fb4d5b">background-color</span> </ul> <li> <a data-link-type="biblio">[CSS-CASCADE-5]</a> defines the following terms: <ul> <li><span class="dfn-paneled" id="d95397a7">all</span> <li><span class="dfn-paneled" id="9cd25054">computed value</span> <li><span class="dfn-paneled" id="4d7d3dcd">initial</span> <li><span class="dfn-paneled" id="9ea6bed2">initial value</span> </ul> <li> <a data-link-type="biblio">[CSS-CONDITIONAL-3]</a> defines the following terms: <ul> <li><span class="dfn-paneled" id="5f1b7f60">@media</span> </ul> <li> <a data-link-type="biblio">[CSS-FONTS-4]</a> defines the following terms: <ul> <li><span class="dfn-paneled" id="fdf6efd5">font-size</span> </ul> <li> <a data-link-type="biblio">[CSS-PROPERTIES-VALUES-API-1]</a> defines the following terms: <ul> <li><span class="dfn-paneled" id="f5848d5e">registered custom property</span> </ul> <li> <a data-link-type="biblio">[CSS-SYNTAX-3]</a> defines the following terms: <ul> <li><span class="dfn-paneled" id="fcd4cfdb"><)-token></span> <li><span class="dfn-paneled" id="40bd5e29"><]-token></span> <li><span class="dfn-paneled" id="f20bb4b1"><bad-string-token></span> <li><span class="dfn-paneled" id="c086086a"><bad-url-token></span> <li><span class="dfn-paneled" id="8144e597"><declaration-value></span> <li><span class="dfn-paneled" id="860c17f8"><delim-token></span> <li><span class="dfn-paneled" id="aa917269"><semicolon-token></span> <li><span class="dfn-paneled" id="f8c04a24"><}-token></span> </ul> <li> <a data-link-type="biblio">[CSS-VALUES-4]</a> defines the following terms: <ul> <li><span class="dfn-paneled" id="9f9120ff">,</span> <li><span class="dfn-paneled" id="8a427103"><dashed-ident></span> <li><span class="dfn-paneled" id="537cf076">?</span> <li><span class="dfn-paneled" id="358fd6ff">CSS-wide keywords</span> <li><span class="dfn-paneled" id="e8ff0bb4">em</span> <li><span class="dfn-paneled" id="9dc6ce48">identifier</span> </ul> <li> <a data-link-type="biblio">[CSS-VALUES-5]</a> defines the following terms: <ul> <li><span class="dfn-paneled" id="4c50974c">arbitrary substitution</span> <li><span class="dfn-paneled" id="346d2bb2">arbitrary substitution function</span> <li><span class="dfn-paneled" id="54fd6ed6">invalid at computed-value time</span> <li><span class="dfn-paneled" id="c525229f">resolve an arbitrary substitution function</span> </ul> <li> <a data-link-type="biblio">[CSSOM-1]</a> defines the following terms: <ul> <li><span class="dfn-paneled" id="b4632a2b">case-sensitive flag</span> <li><span class="dfn-paneled" id="e4ffca7f">declarations</span> <li><span class="dfn-paneled" id="4a3be6e5">getPropertyValue(property)</span> <li><span class="dfn-paneled" id="b360d8c7">removeProperty(property)</span> <li><span class="dfn-paneled" id="668d4884">setProperty(property, value)</span> </ul> <li> <a data-link-type="biblio">[ECMASCRIPT]</a> defines the following terms: <ul> <li><span class="dfn-paneled" id="161cb46c">trim()</span> </ul> <li> <a data-link-type="biblio">[INFRA]</a> defines the following terms: <ul> <li><span class="dfn-paneled" id="7f9469b5">ASCII case-insensitive</span> <li><span class="dfn-paneled" id="91c016b5">identical to</span> </ul> <li> <a data-link-type="biblio">[SELECTORS-4]</a> defines the following terms: <ul> <li><span class="dfn-paneled" id="9e6793fe">:lang()</span> </ul> <li> <a data-link-type="biblio">[WEB-ANIMATIONS-1]</a> defines the following terms: <ul> <li><span class="dfn-paneled" id="7362dc35">not animatable</span> </ul> </ul> <h2 class="no-num no-ref heading settled" id="references"><span class="content">References</span><a class="self-link" href="#references"></a></h2> <h3 class="no-num no-ref heading settled" id="normative"><span class="content">Normative References</span><a class="self-link" href="#normative"></a></h3> <dl> <dt id="biblio-css-animations-1">[CSS-ANIMATIONS-1] <dd>David Baron; et al. <a href="https://drafts.csswg.org/css-animations/"><cite>CSS Animations Level 1</cite></a>. URL: <a href="https://drafts.csswg.org/css-animations/">https://drafts.csswg.org/css-animations/</a> <dt id="biblio-css-cascade-5">[CSS-CASCADE-5] <dd>Elika Etemad; Miriam Suzanne; Tab Atkins Jr.. <a href="https://drafts.csswg.org/css-cascade-5/"><cite>CSS Cascading and Inheritance Level 5</cite></a>. URL: <a href="https://drafts.csswg.org/css-cascade-5/">https://drafts.csswg.org/css-cascade-5/</a> <dt id="biblio-css-conditional-3">[CSS-CONDITIONAL-3] <dd>Chris Lilley; David Baron; Elika Etemad. <a href="https://drafts.csswg.org/css-conditional-3/"><cite>CSS Conditional Rules Module Level 3</cite></a>. URL: <a href="https://drafts.csswg.org/css-conditional-3/">https://drafts.csswg.org/css-conditional-3/</a> <dt id="biblio-css-properties-values-api-1">[CSS-PROPERTIES-VALUES-API-1] <dd>Tab Atkins Jr.; Alan Stearns; Greg Whitworth. <a href="https://drafts.css-houdini.org/css-properties-values-api-1/"><cite>CSS Properties and Values API Level 1</cite></a>. URL: <a href="https://drafts.css-houdini.org/css-properties-values-api-1/">https://drafts.css-houdini.org/css-properties-values-api-1/</a> <dt id="biblio-css-syntax-3">[CSS-SYNTAX-3] <dd>Tab Atkins Jr.; Simon Sapin. <a href="https://drafts.csswg.org/css-syntax/"><cite>CSS Syntax Module Level 3</cite></a>. URL: <a href="https://drafts.csswg.org/css-syntax/">https://drafts.csswg.org/css-syntax/</a> <dt id="biblio-css-values-3">[CSS-VALUES-3] <dd>Tab Atkins Jr.; Elika Etemad. <a href="https://drafts.csswg.org/css-values-3/"><cite>CSS Values and Units Module Level 3</cite></a>. URL: <a href="https://drafts.csswg.org/css-values-3/">https://drafts.csswg.org/css-values-3/</a> <dt id="biblio-css-values-4">[CSS-VALUES-4] <dd>Tab Atkins Jr.; Elika Etemad. <a href="https://drafts.csswg.org/css-values-4/"><cite>CSS Values and Units Module Level 4</cite></a>. URL: <a href="https://drafts.csswg.org/css-values-4/">https://drafts.csswg.org/css-values-4/</a> <dt id="biblio-css-values-5">[CSS-VALUES-5] <dd>Tab Atkins Jr.; Elika Etemad; Miriam Suzanne. <a href="https://drafts.csswg.org/css-values-5/"><cite>CSS Values and Units Module Level 5</cite></a>. URL: <a href="https://drafts.csswg.org/css-values-5/">https://drafts.csswg.org/css-values-5/</a> <dt id="biblio-css2">[CSS2] <dd>Bert Bos; et al. <a href="https://drafts.csswg.org/css2/"><cite>Cascading Style Sheets Level 2 Revision 1 (CSS 2.1) Specification</cite></a>. URL: <a href="https://drafts.csswg.org/css2/">https://drafts.csswg.org/css2/</a> <dt id="biblio-cssom-1">[CSSOM-1] <dd>Daniel Glazman; Emilio Cobos Álvarez. <a href="https://drafts.csswg.org/cssom/"><cite>CSS Object Model (CSSOM)</cite></a>. URL: <a href="https://drafts.csswg.org/cssom/">https://drafts.csswg.org/cssom/</a> <dt id="biblio-infra">[INFRA] <dd>Anne van Kesteren; Domenic Denicola. <a href="https://infra.spec.whatwg.org/"><cite>Infra Standard</cite></a>. Living Standard. URL: <a href="https://infra.spec.whatwg.org/">https://infra.spec.whatwg.org/</a> <dt id="biblio-rfc2119">[RFC2119] <dd>S. Bradner. <a href="https://datatracker.ietf.org/doc/html/rfc2119"><cite>Key words for use in RFCs to Indicate Requirement Levels</cite></a>. March 1997. Best Current Practice. URL: <a href="https://datatracker.ietf.org/doc/html/rfc2119">https://datatracker.ietf.org/doc/html/rfc2119</a> <dt id="biblio-selectors-4">[SELECTORS-4] <dd>Elika Etemad; Tab Atkins Jr.. <a href="https://drafts.csswg.org/selectors/"><cite>Selectors Level 4</cite></a>. URL: <a href="https://drafts.csswg.org/selectors/">https://drafts.csswg.org/selectors/</a> <dt id="biblio-web-animations-1">[WEB-ANIMATIONS-1] <dd>Brian Birtles; et al. <a href="https://drafts.csswg.org/web-animations-1/"><cite>Web Animations</cite></a>. URL: <a href="https://drafts.csswg.org/web-animations-1/">https://drafts.csswg.org/web-animations-1/</a> </dl> <h3 class="no-num no-ref heading settled" id="informative"><span class="content">Informative References</span><a class="self-link" href="#informative"></a></h3> <dl> <dt id="biblio-charmod-norm">[CHARMOD-NORM] <dd>Addison Phillips; et al. <a href="https://w3c.github.io/charmod-norm/"><cite>Character Model for the World Wide Web: String Matching</cite></a>. URL: <a href="https://w3c.github.io/charmod-norm/">https://w3c.github.io/charmod-norm/</a> <dt id="biblio-css-backgrounds-3">[CSS-BACKGROUNDS-3] <dd>Elika Etemad; Brad Kemper. <a href="https://drafts.csswg.org/css-backgrounds/"><cite>CSS Backgrounds and Borders Module Level 3</cite></a>. URL: <a href="https://drafts.csswg.org/css-backgrounds/">https://drafts.csswg.org/css-backgrounds/</a> <dt id="biblio-css-extensions">[CSS-EXTENSIONS] <dd>Tab Atkins Jr.. <a href="https://drafts.csswg.org/css-extensions/"><cite>CSS Extensions</cite></a>. ED. URL: <a href="https://drafts.csswg.org/css-extensions/">https://drafts.csswg.org/css-extensions/</a> <dt id="biblio-css-fonts-4">[CSS-FONTS-4] <dd>Chris Lilley. <a href="https://drafts.csswg.org/css-fonts-4/"><cite>CSS Fonts Module Level 4</cite></a>. URL: <a href="https://drafts.csswg.org/css-fonts-4/">https://drafts.csswg.org/css-fonts-4/</a> <dt id="biblio-ecmascript">[ECMASCRIPT] <dd><a href="https://tc39.es/ecma262/multipage/"><cite>ECMAScript Language Specification</cite></a>. URL: <a href="https://tc39.es/ecma262/multipage/">https://tc39.es/ecma262/multipage/</a> </dl> <h2 class="no-num no-ref heading settled" id="property-index"><span class="content">Property Index</span><a class="self-link" href="#property-index"></a></h2> <div class="big-element-wrapper"> <table class="index"> <thead> <tr> <th scope="col">Name <th scope="col">Value <th scope="col">Initial <th scope="col">Applies to <th scope="col">Inh. <th scope="col">%ages <th scope="col">Animation type <th scope="col">Canonical order <th scope="col">Computed value <tbody> <tr> <th scope="row"><a class="css" data-link-type="property">--*</a> <td><declaration-value>? <td>the guaranteed-invalid value <td>all elements and all pseudo-elements (including those with restricted property lists) <td>yes <td>n/a <td>discrete <td>per grammar <td>specified value with variables substituted, or the guaranteed-invalid value </table> </div> <details class="mdn-anno unpositioned" data-anno-for="using-variables"> <summary><b class="all-engines-flag" title="This feature is in all current engines.">✔</b><span>MDN</span></summary> <div class="feature"> <p><a href="https://developer.mozilla.org/en-US/docs/Web/CSS/var()" title="The var() CSS function can be used to insert the value of a custom property (sometimes called a "CSS variable") instead of any part of a value of another property.">var()</a></p> <p class="all-engines-text">In all current engines.</p> <div class="support"> <span class="firefox yes"><span>Firefox</span><span>31+</span></span><span class="safari yes"><span>Safari</span><span>9.1+</span></span><span class="chrome yes"><span>Chrome</span><span>49+</span></span> <hr> <span class="opera no"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span> <hr> <span class="edge yes"><span>Edge (Legacy)</span><span>15+</span></span><span class="ie no"><span>IE</span><span>None</span></span> <hr> <span class="firefox_android no"><span>Firefox for Android</span><span>?</span></span><span class="safari_ios no"><span>iOS Safari</span><span>?</span></span><span class="chrome_android no"><span>Chrome for Android</span><span>?</span></span><span class="webview_android yes"><span>Android WebView</span><span>50+</span></span><span class="samsunginternet_android no"><span>Samsung Internet</span><span>?</span></span><span class="opera_android no"><span>Opera Mobile</span><span>?</span></span> </div> </div> </details> <details class="mdn-anno unpositioned" data-anno-for="defining-variables"> <summary><b class="all-engines-flag" title="This feature is in all current engines.">✔</b><span>MDN</span></summary> <div class="feature"> <p><a href="https://developer.mozilla.org/en-US/docs/Web/CSS/--*" title="Property names that are prefixed with --, like --example-name, represent custom properties that contain a value that can be used in other declarations using the var() function.">--*</a></p> <p class="all-engines-text">In all current engines.</p> <div class="support"> <span class="firefox yes"><span>Firefox</span><span>31+</span></span><span class="safari yes"><span>Safari</span><span>9.1+</span></span><span class="chrome yes"><span>Chrome</span><span>49+</span></span> <hr> <span class="opera no"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span> <hr> <span class="edge yes"><span>Edge (Legacy)</span><span>15+</span></span><span class="ie no"><span>IE</span><span>None</span></span> <hr> <span class="firefox_android no"><span>Firefox for Android</span><span>?</span></span><span class="safari_ios no"><span>iOS Safari</span><span>?</span></span><span class="chrome_android no"><span>Chrome for Android</span><span>?</span></span><span class="webview_android no"><span>Android WebView</span><span>?</span></span><span class="samsunginternet_android no"><span>Samsung Internet</span><span>?</span></span><span class="opera_android no"><span>Opera Mobile</span><span>?</span></span> </div> </div> </details> <script>/* Boilerplate: script-dom-helper */ "use strict"; function query(sel) { return document.querySelector(sel); } function queryAll(sel) { return [...document.querySelectorAll(sel)]; } function iter(obj) { if(!obj) return []; var it = obj[Symbol.iterator]; if(it) return it; return Object.entries(obj); } function mk(tagname, attrs, ...children) { const el = document.createElement(tagname); for(const [k,v] of iter(attrs)) { if(k.slice(0,3) == "_on") { const eventName = k.slice(3); el.addEventListener(eventName, v); } else if(k[0] == "_") { // property, not attribute el[k.slice(1)] = v; } else { if(v === false || v == null) { continue; } else if(v === true) { el.setAttribute(k, ""); continue; } else { el.setAttribute(k, v); } } } append(el, children); return el; } /* Create shortcuts for every known HTML element */ [ "a", "abbr", "acronym", "address", "applet", "area", "article", "aside", "audio", "b", "base", "basefont", "bdo", "big", "blockquote", "body", "br", "button", "canvas", "caption", "center", "cite", "code", "col", "colgroup", "datalist", "dd", "del", "details", "dfn", "dialog", "div", "dl", "dt", "em", "embed", "fieldset", "figcaption", "figure", "font", "footer", "form", "frame", "frameset", "head", "header", "h1", "h2", "h3", "h4", "h5", "h6", "hr", "html", "i", "iframe", "img", "input", "ins", "kbd", "label", "legend", "li", "link", "main", "map", "mark", "meta", "meter", "nav", "nobr", "noscript", "object", "ol", "optgroup", "option", "output", "p", "param", "pre", "progress", "q", "s", "samp", "script", "section", "select", "small", "source", "span", "strike", "strong", "style", "sub", "summary", "sup", "table", "tbody", "td", "template", "textarea", "tfoot", "th", "thead", "time", "title", "tr", "u", "ul", "var", "video", "wbr", "xmp", ].forEach(tagname=>{ mk[tagname] = (...args) => mk(tagname, ...args); }); function* nodesFromChildList(children) { for(const child of children.flat(Infinity)) { if(child instanceof Node) { yield child; } else { yield new Text(child); } } } function append(el, ...children) { for(const child of nodesFromChildList(children)) { if(el instanceof Node) el.appendChild(child); else el.push(child); } return el; } function insertAfter(el, ...children) { for(const child of nodesFromChildList(children)) { el.parentNode.insertBefore(child, el.nextSibling); } return el; } function clearContents(el) { el.innerHTML = ""; return el; } function parseHTML(markup) { if(markup.toLowerCase().trim().indexOf('<!doctype') === 0) { const doc = document.implementation.createHTMLDocument(""); doc.documentElement.innerHTML = markup; return doc; } else { const el = mk.template({}); el.innerHTML = markup; return el.content; } }</script> <script>/* Boilerplate: script-dfn-panel */ "use strict"; { let dfnPanelData = { "11fb4d5b": {"dfnID":"11fb4d5b","dfnText":"background-color","external":true,"refSections":[{"refs":[{"id":"ref-for-propdef-background-color"}],"title":"2. \nDefining Custom Properties: the --* family of properties"}],"url":"https://drafts.csswg.org/css-backgrounds-3/#propdef-background-color"}, "161cb46c": {"dfnID":"161cb46c","dfnText":"trim()","external":true,"refSections":[{"refs":[{"id":"ref-for-sec-string.prototype.trim"}],"title":"4.1. \nSerializing Custom Properties"}],"url":"https://tc39.es/ecma262/multipage/text-processing.html#sec-string.prototype.trim"}, "346d2bb2": {"dfnID":"346d2bb2","dfnText":"arbitrary substitution function","external":true,"refSections":[{"refs":[{"id":"ref-for-arbitrary-substitution-function"}],"title":"2.2. \nGuaranteed-Invalid Values"},{"refs":[{"id":"ref-for-arbitrary-substitution-function\u2460"}],"title":"3. \nUsing Cascading Variables: the var() notation"}],"url":"https://drafts.csswg.org/css-values-5/#arbitrary-substitution-function"}, "358fd6ff": {"dfnID":"358fd6ff","dfnText":"CSS-wide keywords","external":true,"refSections":[{"refs":[{"id":"ref-for-css-wide-keywords"}],"title":"1.1. \nValue Definitions"},{"refs":[{"id":"ref-for-css-wide-keywords\u2460"}],"title":"2. \nDefining Custom Properties: the --* family of properties"}],"url":"https://drafts.csswg.org/css-values-4/#css-wide-keywords"}, "40bd5e29": {"dfnID":"40bd5e29","dfnText":"<]-token>","external":true,"refSections":[{"refs":[{"id":"ref-for-tokendef-close-square"}],"title":"2.1. \nCustom Property Value Syntax"}],"url":"https://drafts.csswg.org/css-syntax-3/#tokendef-close-square"}, "4a3be6e5": {"dfnID":"4a3be6e5","dfnText":"getPropertyValue(property)","external":true,"refSections":[{"refs":[{"id":"ref-for-dom-cssstyledeclaration-getpropertyvalue"}],"title":"4. \nAPIs"}],"url":"https://drafts.csswg.org/cssom-1/#dom-cssstyledeclaration-getpropertyvalue"}, "4c50974c": {"dfnID":"4c50974c","dfnText":"arbitrary substitution","external":true,"refSections":[{"refs":[{"id":"ref-for-substitute-arbitrary-substitution-function"}],"title":"2. \nDefining Custom Properties: the --* family of properties"}],"url":"https://drafts.csswg.org/css-values-5/#substitute-arbitrary-substitution-function"}, "4d7d3dcd": {"dfnID":"4d7d3dcd","dfnText":"initial","external":true,"refSections":[{"refs":[{"id":"ref-for-valdef-all-initial"}],"title":"2.2. \nGuaranteed-Invalid Values"}],"url":"https://drafts.csswg.org/css-cascade-5/#valdef-all-initial"}, "537cf076": {"dfnID":"537cf076","dfnText":"?","external":true,"refSections":[{"refs":[{"id":"ref-for-mult-opt"}],"title":"2. \nDefining Custom Properties: the --* family of properties"},{"refs":[{"id":"ref-for-mult-opt\u2460"}],"title":"3. \nUsing Cascading Variables: the var() notation"}],"url":"https://drafts.csswg.org/css-values-4/#mult-opt"}, "54fd6ed6": {"dfnID":"54fd6ed6","dfnText":"invalid at computed-value time","external":true,"refSections":[{"refs":[{"id":"ref-for-invalid-at-computed-value-time"}],"title":"2.2. \nGuaranteed-Invalid Values"},{"refs":[{"id":"ref-for-invalid-at-computed-value-time\u2460"},{"id":"ref-for-invalid-at-computed-value-time\u2461"},{"id":"ref-for-invalid-at-computed-value-time\u2462"}],"title":"2.3. \nResolving Dependency Cycles"},{"refs":[{"id":"ref-for-invalid-at-computed-value-time\u2463"},{"id":"ref-for-invalid-at-computed-value-time\u2464"}],"title":"5.3. \nChanges Since the 03 December 2015 CR"}],"url":"https://drafts.csswg.org/css-values-5/#invalid-at-computed-value-time"}, "5f1b7f60": {"dfnID":"5f1b7f60","dfnText":"@media","external":true,"refSections":[{"refs":[{"id":"ref-for-at-ruledef-media"}],"title":"2. \nDefining Custom Properties: the --* family of properties"}],"url":"https://drafts.csswg.org/css-conditional-3/#at-ruledef-media"}, "668d4884": {"dfnID":"668d4884","dfnText":"setProperty(property, value)","external":true,"refSections":[{"refs":[{"id":"ref-for-dom-cssstyledeclaration-setproperty"}],"title":"4.1. \nSerializing Custom Properties"}],"url":"https://drafts.csswg.org/cssom-1/#dom-cssstyledeclaration-setproperty"}, "7362dc35": {"dfnID":"7362dc35","dfnText":"not animatable","external":true,"refSections":[{"refs":[{"id":"ref-for-not-animatable"}],"title":"3. \nUsing Cascading Variables: the var() notation"}],"url":"https://drafts.csswg.org/web-animations-1/#not-animatable"}, "7f9469b5": {"dfnID":"7f9469b5","dfnText":"ASCII case-insensitive","external":true,"refSections":[{"refs":[{"id":"ref-for-ascii-case-insensitive"}],"title":"2. \nDefining Custom Properties: the --* family of properties"},{"refs":[{"id":"ref-for-ascii-case-insensitive\u2460"}],"title":"2.1. \nCustom Property Value Syntax"},{"refs":[{"id":"ref-for-ascii-case-insensitive\u2461"}],"title":"4.1. \nSerializing Custom Properties"}],"url":"https://infra.spec.whatwg.org/#ascii-case-insensitive"}, "8144e597": {"dfnID":"8144e597","dfnText":"<declaration-value>","external":true,"refSections":[{"refs":[{"id":"ref-for-typedef-declaration-value"}],"title":"2. \nDefining Custom Properties: the --* family of properties"},{"refs":[{"id":"ref-for-typedef-declaration-value\u2460"}],"title":"2.1. \nCustom Property Value Syntax"},{"refs":[{"id":"ref-for-typedef-declaration-value\u2461"}],"title":"3. \nUsing Cascading Variables: the var() notation"},{"refs":[{"id":"ref-for-typedef-declaration-value\u2462"}],"title":"5.3. \nChanges Since the 03 December 2015 CR"}],"url":"https://drafts.csswg.org/css-syntax-3/#typedef-declaration-value"}, "860c17f8": {"dfnID":"860c17f8","dfnText":"<delim-token>","external":true,"refSections":[{"refs":[{"id":"ref-for-typedef-delim-token"}],"title":"2.1. \nCustom Property Value Syntax"}],"url":"https://drafts.csswg.org/css-syntax-3/#typedef-delim-token"}, "8a427103": {"dfnID":"8a427103","dfnText":"<dashed-ident>","external":true,"refSections":[{"refs":[{"id":"ref-for-typedef-dashed-ident"}],"title":"2. \nDefining Custom Properties: the --* family of properties"}],"url":"https://drafts.csswg.org/css-values-4/#typedef-dashed-ident"}, "91c016b5": {"dfnID":"91c016b5","dfnText":"identical to","external":true,"refSections":[{"refs":[{"id":"ref-for-string-is"},{"id":"ref-for-string-is\u2460"}],"title":"2. \nDefining Custom Properties: the --* family of properties"}],"url":"https://infra.spec.whatwg.org/#string-is"}, "9cd25054": {"dfnID":"9cd25054","dfnText":"computed value","external":true,"refSections":[{"refs":[{"id":"ref-for-computed-value"}],"title":"2.2. \nGuaranteed-Invalid Values"}],"url":"https://drafts.csswg.org/css-cascade-5/#computed-value"}, "9dc6ce48": {"dfnID":"9dc6ce48","dfnText":"identifier","external":true,"refSections":[{"refs":[{"id":"ref-for-css-css-identifier"}],"title":"2. \nDefining Custom Properties: the --* family of properties"}],"url":"https://drafts.csswg.org/css-values-4/#css-css-identifier"}, "9e6793fe": {"dfnID":"9e6793fe","dfnText":":lang()","external":true,"refSections":[{"refs":[{"id":"ref-for-lang-pseudo"}],"title":"5.4. \nChanges since the May 6 2014 Last Call Working Draft"}],"url":"https://drafts.csswg.org/selectors-4/#lang-pseudo"}, "9ea6bed2": {"dfnID":"9ea6bed2","dfnText":"initial value","external":true,"refSections":[{"refs":[{"id":"ref-for-initial-value"}],"title":"2.2. \nGuaranteed-Invalid Values"}],"url":"https://drafts.csswg.org/css-cascade-5/#initial-value"}, "9f9120ff": {"dfnID":"9f9120ff","dfnText":",","external":true,"refSections":[{"refs":[{"id":"ref-for-comb-comma"},{"id":"ref-for-comb-comma\u2460"}],"title":"3. \nUsing Cascading Variables: the var() notation"}],"url":"https://drafts.csswg.org/css-values-4/#comb-comma"}, "aa917269": {"dfnID":"aa917269","dfnText":"<semicolon-token>","external":true,"refSections":[{"refs":[{"id":"ref-for-typedef-semicolon-token"}],"title":"2.1. \nCustom Property Value Syntax"}],"url":"https://drafts.csswg.org/css-syntax-3/#typedef-semicolon-token"}, "animation-tainted": {"dfnID":"animation-tainted","dfnText":"animation-tainted","external":false,"refSections":[{"refs":[{"id":"ref-for-animation-tainted"},{"id":"ref-for-animation-tainted\u2460"},{"id":"ref-for-animation-tainted\u2461"}],"title":"2. \nDefining Custom Properties: the --* family of properties"},{"refs":[{"id":"ref-for-animation-tainted\u2462"}],"title":"3. \nUsing Cascading Variables: the var() notation"}],"url":"#animation-tainted"}, "b360d8c7": {"dfnID":"b360d8c7","dfnText":"removeProperty(property)","external":true,"refSections":[{"refs":[{"id":"ref-for-dom-cssstyledeclaration-removeproperty"}],"title":"4.1. \nSerializing Custom Properties"}],"url":"https://drafts.csswg.org/cssom-1/#dom-cssstyledeclaration-removeproperty"}, "b4632a2b": {"dfnID":"b4632a2b","dfnText":"case-sensitive flag","external":true,"refSections":[{"refs":[{"id":"ref-for-css-declaration-case-sensitive-flag"}],"title":"4. \nAPIs"}],"url":"https://drafts.csswg.org/cssom-1/#css-declaration-case-sensitive-flag"}, "c086086a": {"dfnID":"c086086a","dfnText":"<bad-url-token>","external":true,"refSections":[{"refs":[{"id":"ref-for-typedef-bad-url-token"}],"title":"2.1. \nCustom Property Value Syntax"}],"url":"https://drafts.csswg.org/css-syntax-3/#typedef-bad-url-token"}, "c525229f": {"dfnID":"c525229f","dfnText":"resolve an arbitrary substitution function","external":true,"refSections":[{"refs":[{"id":"ref-for-resolve-an-arbitrary-substitution-function"}],"title":"3. \nUsing Cascading Variables: the var() notation"}],"url":"https://drafts.csswg.org/css-values-5/#resolve-an-arbitrary-substitution-function"}, "custom-property": {"dfnID":"custom-property","dfnText":"custom property","external":false,"refSections":[{"refs":[{"id":"ref-for-custom-property"},{"id":"ref-for-custom-property\u2460"}],"title":"1. \nIntroduction"},{"refs":[{"id":"ref-for-custom-property\u2461"},{"id":"ref-for-custom-property\u2462"},{"id":"ref-for-custom-property\u2463"},{"id":"ref-for-custom-property\u2464"},{"id":"ref-for-custom-property\u2465"},{"id":"ref-for-custom-property\u2466"},{"id":"ref-for-custom-property\u2467"}],"title":"2. \nDefining Custom Properties: the --* family of properties"},{"refs":[{"id":"ref-for-custom-property\u2468"},{"id":"ref-for-custom-property\u2460\u24ea"},{"id":"ref-for-custom-property\u2460\u2460"}],"title":"2.1. \nCustom Property Value Syntax"},{"refs":[{"id":"ref-for-custom-property\u2460\u2461"},{"id":"ref-for-custom-property\u2460\u2462"},{"id":"ref-for-custom-property\u2460\u2463"}],"title":"2.2. \nGuaranteed-Invalid Values"},{"refs":[{"id":"ref-for-custom-property\u2460\u2464"},{"id":"ref-for-custom-property\u2460\u2465"},{"id":"ref-for-custom-property\u2460\u2466"},{"id":"ref-for-custom-property\u2460\u2467"},{"id":"ref-for-custom-property\u2460\u2468"},{"id":"ref-for-custom-property\u2461\u24ea"}],"title":"2.3. \nResolving Dependency Cycles"},{"refs":[{"id":"ref-for-custom-property\u2461\u2460"},{"id":"ref-for-custom-property\u2461\u2461"},{"id":"ref-for-custom-property\u2461\u2462"},{"id":"ref-for-custom-property\u2461\u2463"},{"id":"ref-for-custom-property\u2461\u2464"},{"id":"ref-for-custom-property\u2461\u2465"}],"title":"3. \nUsing Cascading Variables: the var() notation"},{"refs":[{"id":"ref-for-custom-property\u2461\u2466"}],"title":"4. \nAPIs"},{"refs":[{"id":"ref-for-custom-property\u2461\u2467"},{"id":"ref-for-custom-property\u2461\u2468"}],"title":"4.1. \nSerializing Custom Properties"}],"url":"#custom-property"}, "d95397a7": {"dfnID":"d95397a7","dfnText":"all","external":true,"refSections":[{"refs":[{"id":"ref-for-propdef-all"}],"title":"2. \nDefining Custom Properties: the --* family of properties"}],"url":"https://drafts.csswg.org/css-cascade-5/#propdef-all"}, "e4ffca7f": {"dfnID":"e4ffca7f","dfnText":"declarations","external":true,"refSections":[{"refs":[{"id":"ref-for-cssstyledeclaration-declarations"}],"title":"4. \nAPIs"}],"url":"https://drafts.csswg.org/cssom-1/#cssstyledeclaration-declarations"}, "e8ff0bb4": {"dfnID":"e8ff0bb4","dfnText":"em","external":true,"refSections":[{"refs":[{"id":"ref-for-em"}],"title":"2.3. \nResolving Dependency Cycles"}],"url":"https://drafts.csswg.org/css-values-4/#em"}, "f20bb4b1": {"dfnID":"f20bb4b1","dfnText":"<bad-string-token>","external":true,"refSections":[{"refs":[{"id":"ref-for-typedef-bad-string-token"}],"title":"2.1. \nCustom Property Value Syntax"}],"url":"https://drafts.csswg.org/css-syntax-3/#typedef-bad-string-token"}, "f5848d5e": {"dfnID":"f5848d5e","dfnText":"registered custom property","external":true,"refSections":[{"refs":[{"id":"ref-for-registered-custom-property"}],"title":"2. \nDefining Custom Properties: the --* family of properties"},{"refs":[{"id":"ref-for-registered-custom-property\u2460"}],"title":"5.3. \nChanges Since the 03 December 2015 CR"}],"url":"https://drafts.css-houdini.org/css-properties-values-api-1/#registered-custom-property"}, "f5eca8c9": {"dfnID":"f5eca8c9","dfnText":"background","external":true,"refSections":[{"refs":[{"id":"ref-for-propdef-background"}],"title":"2.1. \nCustom Property Value Syntax"}],"url":"https://drafts.csswg.org/css-backgrounds-3/#propdef-background"}, "f8c04a24": {"dfnID":"f8c04a24","dfnText":"<}-token>","external":true,"refSections":[{"refs":[{"id":"ref-for-tokendef-close-curly"}],"title":"2.1. \nCustom Property Value Syntax"}],"url":"https://drafts.csswg.org/css-syntax-3/#tokendef-close-curly"}, "fa19c68e": {"dfnID":"fa19c68e","dfnText":"@keyframes","external":true,"refSections":[{"refs":[{"id":"ref-for-at-ruledef-keyframes"}],"title":"2. \nDefining Custom Properties: the --* family of properties"}],"url":"https://drafts.csswg.org/css-animations-1/#at-ruledef-keyframes"}, "fcd4cfdb": {"dfnID":"fcd4cfdb","dfnText":"<)-token>","external":true,"refSections":[{"refs":[{"id":"ref-for-tokendef-close-paren"}],"title":"2.1. \nCustom Property Value Syntax"}],"url":"https://drafts.csswg.org/css-syntax-3/#tokendef-close-paren"}, "fdf6efd5": {"dfnID":"fdf6efd5","dfnText":"font-size","external":true,"refSections":[{"refs":[{"id":"ref-for-propdef-font-size"}],"title":"2.3. \nResolving Dependency Cycles"}],"url":"https://drafts.csswg.org/css-fonts-4/#propdef-font-size"}, "funcdef-var": {"dfnID":"funcdef-var","dfnText":"var()","external":false,"refSections":[{"refs":[{"id":"ref-for-funcdef-var"}],"title":"1. \nIntroduction"},{"refs":[{"id":"ref-for-funcdef-var\u2460"},{"id":"ref-for-funcdef-var\u2461"},{"id":"ref-for-funcdef-var\u2462"},{"id":"ref-for-funcdef-var\u2463"},{"id":"ref-for-funcdef-var\u2464"}],"title":"2. \nDefining Custom Properties: the --* family of properties"},{"refs":[{"id":"ref-for-funcdef-var\u2465"},{"id":"ref-for-funcdef-var\u2466"},{"id":"ref-for-funcdef-var\u2467"},{"id":"ref-for-funcdef-var\u2468"},{"id":"ref-for-funcdef-var\u2460\u24ea"},{"id":"ref-for-funcdef-var\u2460\u2460"}],"title":"2.1. \nCustom Property Value Syntax"},{"refs":[{"id":"ref-for-funcdef-var\u2460\u2461"},{"id":"ref-for-funcdef-var\u2460\u2462"},{"id":"ref-for-funcdef-var\u2460\u2463"},{"id":"ref-for-funcdef-var\u2460\u2464"},{"id":"ref-for-funcdef-var\u2460\u2465"}],"title":"2.3. \nResolving Dependency Cycles"},{"refs":[{"id":"ref-for-funcdef-var\u2460\u2466"},{"id":"ref-for-funcdef-var\u2460\u2467"},{"id":"ref-for-funcdef-var\u2460\u2468"},{"id":"ref-for-funcdef-var\u2461\u24ea"},{"id":"ref-for-funcdef-var\u2461\u2460"},{"id":"ref-for-funcdef-var\u2461\u2461"},{"id":"ref-for-funcdef-var\u2461\u2462"},{"id":"ref-for-funcdef-var\u2461\u2463"}],"title":"3. \nUsing Cascading Variables: the var() notation"},{"refs":[{"id":"ref-for-funcdef-var\u2461\u2464"}],"title":"4.1. \nSerializing Custom Properties"},{"refs":[{"id":"ref-for-funcdef-var\u2461\u2465"},{"id":"ref-for-funcdef-var\u2461\u2466"}],"title":"5.3. \nChanges Since the 03 December 2015 CR"},{"refs":[{"id":"ref-for-funcdef-var\u2461\u2467"},{"id":"ref-for-funcdef-var\u2461\u2468"}],"title":"5.4. \nChanges since the May 6 2014 Last Call Working Draft"},{"refs":[{"id":"ref-for-funcdef-var\u2462\u24ea"}],"title":"8. Security Considerations"}],"url":"#funcdef-var"}, "guaranteed-invalid-value": {"dfnID":"guaranteed-invalid-value","dfnText":"guaranteed-invalid value","external":false,"refSections":[{"refs":[{"id":"ref-for-guaranteed-invalid-value"},{"id":"ref-for-guaranteed-invalid-value\u2460"}],"title":"2. \nDefining Custom Properties: the --* family of properties"},{"refs":[{"id":"ref-for-guaranteed-invalid-value\u2461"},{"id":"ref-for-guaranteed-invalid-value\u2462"},{"id":"ref-for-guaranteed-invalid-value\u2463"},{"id":"ref-for-guaranteed-invalid-value\u2464"},{"id":"ref-for-guaranteed-invalid-value\u2465"},{"id":"ref-for-guaranteed-invalid-value\u2466"}],"title":"2.2. \nGuaranteed-Invalid Values"},{"refs":[{"id":"ref-for-guaranteed-invalid-value\u2467"},{"id":"ref-for-guaranteed-invalid-value\u2468"}],"title":"2.3. \nResolving Dependency Cycles"},{"refs":[{"id":"ref-for-guaranteed-invalid-value\u2460\u24ea"},{"id":"ref-for-guaranteed-invalid-value\u2460\u2460"},{"id":"ref-for-guaranteed-invalid-value\u2460\u2461"}],"title":"3. \nUsing Cascading Variables: the var() notation"},{"refs":[{"id":"ref-for-guaranteed-invalid-value\u2460\u2462"}],"title":"5.3. \nChanges Since the 03 December 2015 CR"}],"url":"#guaranteed-invalid-value"}, "propdef-": {"dfnID":"propdef-","dfnText":"--*","external":false,"refSections":[],"url":"#propdef-"}, "resolve-a-var-function": {"dfnID":"resolve-a-var-function","dfnText":"resolve a var() function","external":false,"refSections":[],"url":"#resolve-a-var-function"}, "typedef-custom-property-name": {"dfnID":"typedef-custom-property-name","dfnText":"<custom-property-name>","external":false,"refSections":[{"refs":[{"id":"ref-for-typedef-custom-property-name"}],"title":"3. \nUsing Cascading Variables: the var() notation"}],"url":"#typedef-custom-property-name"}, }; document.addEventListener("DOMContentLoaded", ()=>{ genAllDfnPanels(); document.body.addEventListener("click", (e) => { // If not handled already, just hide all dfn panels. hideAllDfnPanels(); }); }); window.addEventListener("resize", () => { // Pin any visible dfn panel queryAll(".dfn-panel.on, .dfn-panel.activated").forEach(el=>positionDfnPanel(el)); }); function genAllDfnPanels() { for(const panelData of Object.values(dfnPanelData)) { const dfnID = panelData.dfnID; const dfn = document.getElementById(dfnID); if(!dfn) { console.log(`Can't find dfn#${dfnID}.`, panelData); continue; } dfn.panelData = panelData; insertDfnPopupAction(dfn); } } function genDfnPanel(dfn, { dfnID, url, dfnText, refSections, external }) { const dfnPanel = mk.aside({ class: "dfn-panel on", id: `infopanel-for-${dfnID}`, "data-for": dfnID, "aria-labelled-by":`infopaneltitle-for-${dfnID}`, }, mk.span({id:`infopaneltitle-for-${dfnID}`, style:"display:none"}, `Info about the '${dfnText}' ${external?"external":""} reference.`), mk.a({href:url, class:"dfn-link"}, url), refSections.length == 0 ? [] : mk.b({}, "Referenced in:"), mk.ul({}, ...refSections.map(section=> mk.li({}, ...section.refs.map((ref, refI)=> [ mk.a({ href: `#${ref.id}` }, (refI == 0) ? section.title : `(${refI + 1})` ), " ", ] ), ), ), ), genLinkingSyntaxes(dfn), ); dfnPanel.addEventListener('click', (event) => { if (event.target.nodeName == 'A') { scrollToTargetAndHighlight(event); pinDfnPanel(dfnPanel); } event.stopPropagation(); refocusOnTarget(event); }); dfnPanel.addEventListener('keydown', (event) => { if(event.keyCode == 27) { // Escape key hideDfnPanel({dfnPanel}); event.stopPropagation(); event.preventDefault(); } }); dfnPanel.dfn = dfn; dfn.dfnPanel = dfnPanel; return dfnPanel; } function hideAllDfnPanels() { // Delete the currently-active dfn panel. queryAll(".dfn-panel").forEach(dfnPanel=>hideDfnPanel({dfnPanel})); } function showDfnPanel(dfn) { hideAllDfnPanels(); // Only display one at a time. dfn.setAttribute("aria-expanded", "true"); const dfnPanel = genDfnPanel(dfn, dfn.panelData); // Give the dfn a unique tabindex, and then // give all the tabbable panel bits successive indexes. let tabIndex = 100; dfn.tabIndex = tabIndex++; const tabbable = dfnPanel.querySelectorAll(":is(a, button)"); for (const el of tabbable) { el.tabIndex = tabIndex++; } append(document.body, dfnPanel); positionDfnPanel(dfnPanel); } function positionDfnPanel(dfnPanel) { const dfn = dfnPanel.dfn; const dfnPos = getBounds(dfn); dfnPanel.style.top = dfnPos.bottom + "px"; dfnPanel.style.left = dfnPos.left + "px"; const panelPos = dfnPanel.getBoundingClientRect(); const panelMargin = 8; const maxRight = document.body.parentNode.clientWidth - panelMargin; if (panelPos.right > maxRight) { const overflowAmount = panelPos.right - maxRight; const newLeft = Math.max(panelMargin, dfnPos.left - overflowAmount); dfnPanel.style.left = newLeft + "px"; } } function pinDfnPanel(dfnPanel) { // Switch it to "activated" state, which pins it. dfnPanel.classList.add("activated"); dfnPanel.style.position = "fixed"; dfnPanel.style.left = null; dfnPanel.style.top = null; } function hideDfnPanel({dfn, dfnPanel}) { if(!dfnPanel) dfnPanel = dfn.dfnPanel; if(!dfn) dfn = dfnPanel.dfn; dfn.dfnPanel = undefined; dfnPanel.dfn = undefined; dfn.setAttribute("aria-expanded", "false"); dfn.tabIndex = undefined; dfnPanel.remove() } function toggleDfnPanel(dfn) { if(dfn.dfnPanel) { hideDfnPanel(dfn); } else { showDfnPanel(dfn); } } function insertDfnPopupAction(dfn) { dfn.setAttribute('role', 'button'); dfn.setAttribute('aria-expanded', 'false') dfn.tabIndex = 0; dfn.classList.add('has-dfn-panel'); dfn.addEventListener('click', (event) => { toggleDfnPanel(dfn); event.stopPropagation(); }); dfn.addEventListener('keypress', (event) => { const kc = event.keyCode; // 32->Space, 13->Enter if(kc == 32 || kc == 13) { toggleDfnPanel(dfn); event.stopPropagation(); event.preventDefault(); } }); } function refocusOnTarget(event) { const target = event.target; setTimeout(() => { // Refocus on the event.target element. // This is needed after browser scrolls to the destination. target.focus(); }); } // TODO: shared util // Returns the root-level absolute position {left and top} of element. function getBounds(el, relativeTo=document.body) { const relativeRect = relativeTo.getBoundingClientRect(); const elRect = el.getBoundingClientRect(); const top = elRect.top - relativeRect.top; const left = elRect.left - relativeRect.left; return { top, left, bottom: top + elRect.height, right: left + elRect.width, } } function scrollToTargetAndHighlight(event) { let hash = event.target.hash; if (hash) { hash = decodeURIComponent(hash.substring(1)); const dest = document.getElementById(hash); if (dest) { dest.classList.add('highlighted'); setTimeout(() => dest.classList.remove('highlighted'), 1000); } } } // Functions, divided by link type, that wrap an autolink's // contents with the appropriate outer syntax. // Alternately, a string naming another type they format // the same as. function needsFor(type) { switch(type) { case "descriptor": case "value": case "element-attr": case "attr-value": case "element-state": case "method": case "constructor": case "argument": case "attribute": case "const": case "dict-member": case "event": case "enum-value": case "stringifier": case "serializer": case "iterator": case "maplike": case "setlike": case "state": case "mode": case "context": case "facet": return true; default: return false; } } function refusesFor(type) { switch(type) { case "property": case "element": case "interface": case "namespace": case "callback": case "dictionary": case "enum": case "exception": case "typedef": case "http-header": case "permission": return true; default: return false; } } function linkFormatterFromType(type) { switch(type) { case 'scheme': case 'permission': case 'dfn': return (text) => `[=${text}=]`; case 'abstract-op': return (text) => `[\$${text}\$]`; case 'function': case 'at-rule': case 'selector': case 'value': return (text) => `''${text}''`; case 'http-header': return (text) => `[:${text}:]`; case 'interface': case 'constructor': case 'method': case 'argument': case 'attribute': case 'callback': case 'dictionary': case 'dict-member': case 'enum': case 'enum-value': case 'exception': case 'const': case 'typedef': case 'stringifier': case 'serializer': case 'iterator': case 'maplike': case 'setlike': case 'extended-attribute': case 'event': case 'idl': return (text) => `{{${text}}}`; case 'element-state': case 'element-attr': case 'attr-value': case 'element': return (element) => `<{${element}}>`; case 'grammar': return (text) => `${text} (within a <pre class=prod>)`; case 'type': return (text)=> `<<${text}>>`; case 'descriptor': case 'property': return (text) => `'${text}'`; default: return; }; }; function genLinkingSyntaxes(dfn) { if(dfn.tagName != "DFN") return; const type = dfn.getAttribute('data-dfn-type'); if(!type) { console.log(`<dfn> doesn't have a data-dfn-type:`, dfn); return []; } // Return a function that wraps link text based on the type const linkFormatter = linkFormatterFromType(type); if(!linkFormatter) { console.log(`<dfn> has an unknown data-dfn-type:`, dfn); return []; } let ltAlts; if(dfn.hasAttribute('data-lt')) { ltAlts = dfn.getAttribute('data-lt') .split("|") .map(x=>x.trim()); } else { ltAlts = [dfn.textContent.trim()]; } if(type == "type") { // lt of "<foo>", but "foo" is the interior; // <<foo/bar>> is how you write it with a for, // not <foo/<bar>> or whatever. for(var i = 0; i < ltAlts.length; i++) { const lt = ltAlts[i]; const match = /<(.*)>/.exec(lt); if(match) { ltAlts[i] = match[1]; } } } let forAlts; if(dfn.hasAttribute('data-dfn-for')) { forAlts = dfn.getAttribute('data-dfn-for') .split(",") .map(x=>x.trim()); } else { forAlts = ['']; } let linkingSyntaxes = []; if(!needsFor(type)) { for(const lt of ltAlts) { linkingSyntaxes.push(linkFormatter(lt)); } } if(!refusesFor(type)) { for(const f of forAlts) { linkingSyntaxes.push(linkFormatter(`${f}/${ltAlts[0]}`)) } } return [ mk.b({}, 'Possible linking syntaxes:'), mk.ul({}, ...linkingSyntaxes.map(link => { const copyLink = async () => await navigator.clipboard.writeText(link); return mk.li({}, mk.div({ class: 'link-item' }, mk.button({ class: 'copy-icon', title: 'Copy', type: 'button', _onclick: copyLink, tabindex: 0, }, mk.span({ class: 'icon' }) ), mk.span({}, link) ) ); }) ) ]; } } </script> <script>/* Boilerplate: script-position-annos */ "use strict"; { function repositionAnnoPanels(){ const panels = [...document.querySelectorAll("[data-anno-for]")]; hydratePanels(panels); let vSoFar = 0; for(const panel of panels.sort(cmpTops)) { if(panel.top < vSoFar) { panel.top = vSoFar; panel.style.top = vSoFar + "px"; } vSoFar = panel.top + panel.height + 15; } } function hydratePanels(panels) { const main = document.querySelector("main"); let mainRect; if(main) mainRect = main.getBoundingClientRect(); // First display them all, if they're not already visible. for(const panel of panels) { panel.classList.remove("unpositioned"); } // Measure them all for(const panel of panels) { const dfn = document.getElementById(panel.getAttribute("data-anno-for")); if(!dfn) { console.log("Can't find the annotation panel target:", panel); continue; } panel.dfn = dfn; panel.top = window.scrollY + dfn.getBoundingClientRect().top; let panelRect = panel.getBoundingClientRect(); panel.height = panelRect.height; if(main) { panel.overlappingMain = panelRect.left < mainRect.right; } else { panel.overlappingMain = false; } } // And finally position them for(const panel of panels) { const dfn = panel.dfn; if(!dfn) continue; panel.style.top = panel.top + "px"; panel.classList.toggle("overlapping-main", panel.overlappingMain); } } function cmpTops(a,b) { return a.top - b.top; } window.addEventListener("load", repositionAnnoPanels); window.addEventListener("resize", repositionAnnoPanels); } </script> <script>/* Boilerplate: script-ref-hints */ "use strict"; { let refsData = { "#animation-tainted": {"displayText":"animation-tainted","export":true,"for_":[],"level":"1","normative":true,"shortname":"css-variables","spec":"css-variables-1","status":"local","text":"animation-tainted","type":"dfn","url":"#animation-tainted"}, "#custom-property": {"displayText":"custom property","export":true,"for_":[],"level":"1","normative":true,"shortname":"css-variables","spec":"css-variables-1","status":"local","text":"custom property","type":"dfn","url":"#custom-property"}, "#funcdef-var": {"displayText":"var()","export":true,"for_":[],"level":"1","normative":true,"shortname":"css-variables","spec":"css-variables-1","status":"local","text":"var()","type":"function","url":"#funcdef-var"}, "#guaranteed-invalid-value": {"displayText":"guaranteed-invalid value","export":true,"for_":[],"level":"1","normative":true,"shortname":"css-variables","spec":"css-variables-1","status":"local","text":"guaranteed-invalid value","type":"dfn","url":"#guaranteed-invalid-value"}, "#typedef-custom-property-name": {"displayText":"<custom-property-name>","export":true,"for_":[],"level":"1","normative":true,"shortname":"css-variables","spec":"css-variables-1","status":"local","text":"<custom-property-name>","type":"type","url":"#typedef-custom-property-name"}, "https://drafts.css-houdini.org/css-properties-values-api-1/#registered-custom-property": {"displayText":"registered custom property","export":true,"for_":[],"level":"1","normative":true,"shortname":"css-properties-values-api","spec":"css-properties-values-api-1","status":"current","text":"registered custom property","type":"dfn","url":"https://drafts.css-houdini.org/css-properties-values-api-1/#registered-custom-property"}, "https://drafts.csswg.org/css-animations-1/#at-ruledef-keyframes": {"displayText":"@keyframes","export":true,"for_":[],"level":"1","normative":true,"shortname":"css-animations","spec":"css-animations-1","status":"current","text":"@keyframes","type":"at-rule","url":"https://drafts.csswg.org/css-animations-1/#at-ruledef-keyframes"}, "https://drafts.csswg.org/css-backgrounds-3/#propdef-background": {"displayText":"background","export":true,"for_":[],"level":"3","normative":true,"shortname":"css-backgrounds","spec":"css-backgrounds-3","status":"current","text":"background","type":"property","url":"https://drafts.csswg.org/css-backgrounds-3/#propdef-background"}, "https://drafts.csswg.org/css-backgrounds-3/#propdef-background-color": {"displayText":"background-color","export":true,"for_":[],"level":"3","normative":true,"shortname":"css-backgrounds","spec":"css-backgrounds-3","status":"current","text":"background-color","type":"property","url":"https://drafts.csswg.org/css-backgrounds-3/#propdef-background-color"}, "https://drafts.csswg.org/css-cascade-5/#computed-value": {"displayText":"computed value","export":true,"for_":[],"level":"5","normative":true,"shortname":"css-cascade","spec":"css-cascade-5","status":"current","text":"computed value","type":"dfn","url":"https://drafts.csswg.org/css-cascade-5/#computed-value"}, "https://drafts.csswg.org/css-cascade-5/#initial-value": {"displayText":"initial value","export":true,"for_":[],"level":"5","normative":true,"shortname":"css-cascade","spec":"css-cascade-5","status":"current","text":"initial value","type":"dfn","url":"https://drafts.csswg.org/css-cascade-5/#initial-value"}, "https://drafts.csswg.org/css-cascade-5/#propdef-all": {"displayText":"all","export":true,"for_":[],"level":"5","normative":true,"shortname":"css-cascade","spec":"css-cascade-5","status":"current","text":"all","type":"property","url":"https://drafts.csswg.org/css-cascade-5/#propdef-all"}, "https://drafts.csswg.org/css-cascade-5/#valdef-all-initial": {"displayText":"initial","export":true,"for_":["all"],"level":"5","normative":true,"shortname":"css-cascade","spec":"css-cascade-5","status":"current","text":"initial","type":"value","url":"https://drafts.csswg.org/css-cascade-5/#valdef-all-initial"}, "https://drafts.csswg.org/css-conditional-3/#at-ruledef-media": {"displayText":"@media","export":true,"for_":[],"level":"3","normative":true,"shortname":"css-conditional","spec":"css-conditional-3","status":"current","text":"@media","type":"at-rule","url":"https://drafts.csswg.org/css-conditional-3/#at-ruledef-media"}, "https://drafts.csswg.org/css-fonts-4/#propdef-font-size": {"displayText":"font-size","export":true,"for_":[],"level":"4","normative":true,"shortname":"css-fonts","spec":"css-fonts-4","status":"current","text":"font-size","type":"property","url":"https://drafts.csswg.org/css-fonts-4/#propdef-font-size"}, "https://drafts.csswg.org/css-syntax-3/#tokendef-close-curly": {"displayText":"<}-token>","export":true,"for_":[],"level":"3","normative":true,"shortname":"css-syntax","spec":"css-syntax-3","status":"current","text":"<}-token>","type":"type","url":"https://drafts.csswg.org/css-syntax-3/#tokendef-close-curly"}, "https://drafts.csswg.org/css-syntax-3/#tokendef-close-paren": {"displayText":"<)-token>","export":true,"for_":[],"level":"3","normative":true,"shortname":"css-syntax","spec":"css-syntax-3","status":"current","text":"<)-token>","type":"type","url":"https://drafts.csswg.org/css-syntax-3/#tokendef-close-paren"}, "https://drafts.csswg.org/css-syntax-3/#tokendef-close-square": {"displayText":"<]-token>","export":true,"for_":[],"level":"3","normative":true,"shortname":"css-syntax","spec":"css-syntax-3","status":"current","text":"<]-token>","type":"type","url":"https://drafts.csswg.org/css-syntax-3/#tokendef-close-square"}, "https://drafts.csswg.org/css-syntax-3/#typedef-bad-string-token": {"displayText":"<bad-string-token>","export":true,"for_":[],"level":"3","normative":true,"shortname":"css-syntax","spec":"css-syntax-3","status":"current","text":"<bad-string-token>","type":"type","url":"https://drafts.csswg.org/css-syntax-3/#typedef-bad-string-token"}, "https://drafts.csswg.org/css-syntax-3/#typedef-bad-url-token": {"displayText":"<bad-url-token>","export":true,"for_":[],"level":"3","normative":true,"shortname":"css-syntax","spec":"css-syntax-3","status":"current","text":"<bad-url-token>","type":"type","url":"https://drafts.csswg.org/css-syntax-3/#typedef-bad-url-token"}, "https://drafts.csswg.org/css-syntax-3/#typedef-declaration-value": {"displayText":"<declaration-value>","export":true,"for_":[],"level":"3","normative":true,"shortname":"css-syntax","spec":"css-syntax-3","status":"current","text":"<declaration-value>","type":"type","url":"https://drafts.csswg.org/css-syntax-3/#typedef-declaration-value"}, "https://drafts.csswg.org/css-syntax-3/#typedef-delim-token": {"displayText":"<delim-token>","export":true,"for_":[],"level":"3","normative":true,"shortname":"css-syntax","spec":"css-syntax-3","status":"current","text":"<delim-token>","type":"type","url":"https://drafts.csswg.org/css-syntax-3/#typedef-delim-token"}, "https://drafts.csswg.org/css-syntax-3/#typedef-semicolon-token": {"displayText":"<semicolon-token>","export":true,"for_":[],"level":"3","normative":true,"shortname":"css-syntax","spec":"css-syntax-3","status":"current","text":"<semicolon-token>","type":"type","url":"https://drafts.csswg.org/css-syntax-3/#typedef-semicolon-token"}, "https://drafts.csswg.org/css-values-4/#comb-comma": {"displayText":",","export":true,"for_":[],"level":"4","normative":true,"shortname":"css-values","spec":"css-values-4","status":"current","text":",","type":"grammar","url":"https://drafts.csswg.org/css-values-4/#comb-comma"}, "https://drafts.csswg.org/css-values-4/#css-css-identifier": {"displayText":"identifier","export":true,"for_":["CSS"],"level":"4","normative":true,"shortname":"css-values","spec":"css-values-4","status":"current","text":"identifier","type":"dfn","url":"https://drafts.csswg.org/css-values-4/#css-css-identifier"}, "https://drafts.csswg.org/css-values-4/#css-wide-keywords": {"displayText":"CSS-wide keywords","export":true,"for_":[],"level":"4","normative":true,"shortname":"css-values","spec":"css-values-4","status":"current","text":"css-wide keywords","type":"dfn","url":"https://drafts.csswg.org/css-values-4/#css-wide-keywords"}, "https://drafts.csswg.org/css-values-4/#em": {"displayText":"em","export":true,"for_":["<length>"],"level":"4","normative":true,"shortname":"css-values","spec":"css-values-4","status":"current","text":"em","type":"value","url":"https://drafts.csswg.org/css-values-4/#em"}, "https://drafts.csswg.org/css-values-4/#mult-opt": {"displayText":"?","export":true,"for_":[],"level":"4","normative":true,"shortname":"css-values","spec":"css-values-4","status":"current","text":"?","type":"grammar","url":"https://drafts.csswg.org/css-values-4/#mult-opt"}, "https://drafts.csswg.org/css-values-4/#typedef-dashed-ident": {"displayText":"<dashed-ident>","export":true,"for_":[],"level":"4","normative":true,"shortname":"css-values","spec":"css-values-4","status":"current","text":"<dashed-ident>","type":"type","url":"https://drafts.csswg.org/css-values-4/#typedef-dashed-ident"}, "https://drafts.csswg.org/css-values-5/#arbitrary-substitution-function": {"displayText":"arbitrary substitution function","export":true,"for_":[],"level":"5","normative":true,"shortname":"css-values","spec":"css-values-5","status":"current","text":"arbitrary substitution function","type":"dfn","url":"https://drafts.csswg.org/css-values-5/#arbitrary-substitution-function"}, "https://drafts.csswg.org/css-values-5/#invalid-at-computed-value-time": {"displayText":"invalid at computed-value time","export":true,"for_":[],"level":"5","normative":true,"shortname":"css-values","spec":"css-values-5","status":"current","text":"invalid at computed-value time","type":"dfn","url":"https://drafts.csswg.org/css-values-5/#invalid-at-computed-value-time"}, "https://drafts.csswg.org/css-values-5/#resolve-an-arbitrary-substitution-function": {"displayText":"resolve an arbitrary substitution function","export":true,"for_":[],"level":"5","normative":true,"shortname":"css-values","spec":"css-values-5","status":"current","text":"resolve an arbitrary substitution function","type":"dfn","url":"https://drafts.csswg.org/css-values-5/#resolve-an-arbitrary-substitution-function"}, "https://drafts.csswg.org/css-values-5/#substitute-arbitrary-substitution-function": {"displayText":"arbitrary substitution","export":true,"for_":[],"level":"5","normative":true,"shortname":"css-values","spec":"css-values-5","status":"current","text":"arbitrary substitution","type":"dfn","url":"https://drafts.csswg.org/css-values-5/#substitute-arbitrary-substitution-function"}, "https://drafts.csswg.org/cssom-1/#css-declaration-case-sensitive-flag": {"displayText":"case-sensitive flag","export":false,"for_":["CSS declaration"],"level":"1","normative":true,"shortname":"cssom","spec":"cssom-1","status":"current","text":"case-sensitive flag","type":"dfn","url":"https://drafts.csswg.org/cssom-1/#css-declaration-case-sensitive-flag"}, "https://drafts.csswg.org/cssom-1/#cssstyledeclaration-declarations": {"displayText":"declarations","export":true,"for_":["CSSStyleDeclaration"],"level":"1","normative":true,"shortname":"cssom","spec":"cssom-1","status":"current","text":"declarations","type":"dfn","url":"https://drafts.csswg.org/cssom-1/#cssstyledeclaration-declarations"}, "https://drafts.csswg.org/cssom-1/#dom-cssstyledeclaration-getpropertyvalue": {"displayText":"getPropertyValue(property)","export":true,"for_":["CSSStyleDeclaration"],"level":"1","normative":true,"shortname":"cssom","spec":"cssom-1","status":"current","text":"getPropertyValue(property)","type":"method","url":"https://drafts.csswg.org/cssom-1/#dom-cssstyledeclaration-getpropertyvalue"}, "https://drafts.csswg.org/cssom-1/#dom-cssstyledeclaration-removeproperty": {"displayText":"removeProperty(property)","export":true,"for_":["CSSStyleDeclaration"],"level":"1","normative":true,"shortname":"cssom","spec":"cssom-1","status":"current","text":"removeProperty(property)","type":"method","url":"https://drafts.csswg.org/cssom-1/#dom-cssstyledeclaration-removeproperty"}, "https://drafts.csswg.org/cssom-1/#dom-cssstyledeclaration-setproperty": {"displayText":"setProperty(property, value)","export":true,"for_":["CSSStyleDeclaration"],"level":"1","normative":true,"shortname":"cssom","spec":"cssom-1","status":"current","text":"setProperty(property, value)","type":"method","url":"https://drafts.csswg.org/cssom-1/#dom-cssstyledeclaration-setproperty"}, "https://drafts.csswg.org/selectors-4/#lang-pseudo": {"displayText":":lang()","export":true,"for_":[],"level":"4","normative":true,"shortname":"selectors","spec":"selectors-4","status":"current","text":":lang()","type":"selector","url":"https://drafts.csswg.org/selectors-4/#lang-pseudo"}, "https://drafts.csswg.org/web-animations-1/#not-animatable": {"displayText":"not animatable","export":true,"for_":[],"level":"1","normative":true,"shortname":"web-animations","spec":"web-animations-1","status":"current","text":"not animatable","type":"dfn","url":"https://drafts.csswg.org/web-animations-1/#not-animatable"}, "https://infra.spec.whatwg.org/#ascii-case-insensitive": {"displayText":"ASCII case-insensitive","export":true,"for_":[],"level":"1","normative":true,"shortname":"infra","spec":"infra","status":"current","text":"ascii case-insensitive","type":"dfn","url":"https://infra.spec.whatwg.org/#ascii-case-insensitive"}, "https://infra.spec.whatwg.org/#string-is": {"displayText":"identical to","export":true,"for_":["string"],"level":"1","normative":true,"shortname":"infra","spec":"infra","status":"current","text":"identical to","type":"dfn","url":"https://infra.spec.whatwg.org/#string-is"}, "https://tc39.es/ecma262/multipage/text-processing.html#sec-string.prototype.trim": {"displayText":"trim()","export":true,"for_":["String"],"level":"1","normative":true,"shortname":"ecmascript","spec":"ecmascript","status":"current","text":"trim()","type":"method","url":"https://tc39.es/ecma262/multipage/text-processing.html#sec-string.prototype.trim"}, }; function mkRefHint(link, ref) { const linkText = link.textContent; let dfnTextElements = ''; if (ref.displayText.toLowerCase() != linkText.toLowerCase()) { // Give the original term if it's being displayed in a different way. // But allow casing differences, they're insignificant. dfnTextElements = mk.li({}, mk.b({}, "Term: "), mk.span({}, ref.displayText) ); } const forList = ref.for_; let forListElements; if(forList.length == 0) { forListElements = []; } else if(forList.length == 1) { forListElements = mk.li({}, mk.b({}, "For: "), mk.span({}, forList[0]), ); } else { forListElements = mk.li({}, mk.b({}, "For: "), mk.ul({}, ...forList.map(forItem => mk.li({}, mk.span({}, forItem) ), ), ), ); } const url = ref.url; const safeUrl = encodeURIComponent(url); const hintPanel = mk.aside({ class: "ref-hint", id: `ref-hint-for-${safeUrl}`, "data-for": url, "aria-labelled-by": `ref-hint-for-${safeUrl}`, }, mk.ul({}, dfnTextElements, mk.li({}, mk.b({}, "URL: "), mk.a({ href: url, class: "ref" }, url), ), mk.li({}, mk.b({}, "Type: "), mk.span({}, `${ref.type}`), ), mk.li({}, mk.b({}, "Spec: "), mk.span({}, `${ref.spec ? ref.spec : ''}`), ), forListElements ), ); hintPanel.forLink = link; setupRefHintEventListeners(link, hintPanel); return hintPanel; } function hideAllRefHints() { queryAll(".ref-hint").forEach(el=>hideRefHint(el)); } function hideRefHint(refHint) { const link = refHint.forLink; link.setAttribute("aria-expanded", "false"); if(refHint.teardownEventListeners) { refHint.teardownEventListeners(); } refHint.remove(); } function showRefHint(link) { if(link.classList.contains("dfn-link")) return; const url = link.getAttribute("href"); const refHintKey = link.getAttribute("data-refhint-key"); let key = url; if(refHintKey) { key = refHintKey + "_" + url; } const ref = refsData[key]; if(!ref) return; hideAllRefHints(); // Only display one at this time. const refHint = mkRefHint(link, ref); append(document.body, refHint); link.setAttribute("aria-expanded", "true"); positionRefHint(refHint); } function setupRefHintEventListeners(link, refHint) { if (refHint.teardownEventListeners) return; // Add event handlers to hide the refHint after the user moves away // from both the link and refHint, if not hovering either within one second. let timeout = null; const startHidingRefHint = (event) => { if (timeout) { clearTimeout(timeout); } timeout = setTimeout(() => { hideRefHint(refHint); }, 1000); } const resetHidingRefHint = (event) => { if (timeout) clearTimeout(timeout); timeout = null; }; link.addEventListener("mouseleave", startHidingRefHint); link.addEventListener("mouseenter", resetHidingRefHint); link.addEventListener("blur", startHidingRefHint); link.addEventListener("focus", resetHidingRefHint); refHint.addEventListener("mouseleave", startHidingRefHint); refHint.addEventListener("mouseenter", resetHidingRefHint); refHint.addEventListener("blur", startHidingRefHint); refHint.addEventListener("focus", resetHidingRefHint); refHint.teardownEventListeners = () => { // remove event listeners resetHidingRefHint(); link.removeEventListener("mouseleave", startHidingRefHint); link.removeEventListener("mouseenter", resetHidingRefHint); link.removeEventListener("blur", startHidingRefHint); link.removeEventListener("focus", resetHidingRefHint); refHint.removeEventListener("mouseleave", startHidingRefHint); refHint.removeEventListener("mouseenter", resetHidingRefHint); refHint.removeEventListener("blur", startHidingRefHint); refHint.removeEventListener("focus", resetHidingRefHint); }; } function positionRefHint(refHint) { const link = refHint.forLink; const linkPos = getBounds(link); refHint.style.top = linkPos.bottom + "px"; refHint.style.left = linkPos.left + "px"; const panelPos = refHint.getBoundingClientRect(); const panelMargin = 8; const maxRight = document.body.parentNode.clientWidth - panelMargin; if (panelPos.right > maxRight) { const overflowAmount = panelPos.right - maxRight; const newLeft = Math.max(panelMargin, linkPos.left - overflowAmount); refHint.style.left = newLeft + "px"; } } // TODO: shared util // Returns the root-level absolute position {left and top} of element. function getBounds(el, relativeTo=document.body) { const relativeRect = relativeTo.getBoundingClientRect(); const elRect = el.getBoundingClientRect(); const top = elRect.top - relativeRect.top; const left = elRect.left - relativeRect.left; return { top, left, bottom: top + elRect.height, right: left + elRect.width, } } function showRefHintListener(e) { // If the target isn't in a link (or is a link), // just ignore it. let link = e.target.closest("a"); if(!link) return; // If the target is in a ref-hint panel // (aka a link in the already-open one), // also just ignore it. if(link.closest(".ref-hint")) return; // Otherwise, show the panel for the link. showRefHint(link); } function hideAllHintsListener(e) { // If the click is inside a ref-hint panel, ignore it. if(e.target.closest(".ref-hint")) return; // Otherwise, close all the current panels. hideAllRefHints(); } document.addEventListener("DOMContentLoaded", () => { document.body.addEventListener("mousedown", showRefHintListener); document.body.addEventListener("focus", showRefHintListener); document.body.addEventListener("click", hideAllHintsListener); }); window.addEventListener("resize", () => { // Hide any open ref hint. hideAllRefHints(); }); } </script> <script>/* Boilerplate: script-var-click-highlighting */ "use strict"; { /* Color-choosing design: * Colors are ordered by goodness. * On clicking a var, give it the earliest color with the lowest usage in the algorithm. * On re-clicking, re-use the var's most recent color if that's not currently being used elsewhere. */ const COLOR_COUNT = 7; document.addEventListener("click", e=>{ if(e.target.nodeName == "VAR") { highlightSameAlgoVars(e.target); } }); function highlightSameAlgoVars(v) { // Find the algorithm container. let algoContainer = findAlgoContainer(v); // Not highlighting document-global vars, // too likely to be unrelated. if(algoContainer == null) return; const varName = nameFromVar(v); if(!v.hasAttribute("data-var-color")) { const newColor = chooseHighlightColor(algoContainer, v); for(const el of algoContainer.querySelectorAll("var")) { if(nameFromVar(el) == varName) { el.setAttribute("data-var-color", newColor); el.setAttribute("data-var-last-color", newColor); } } } else { for(const el of algoContainer.querySelectorAll("var")) { if(nameFromVar(el) == varName) { el.removeAttribute("data-var-color"); } } } } function findAlgoContainer(el) { while(el != document.body) { if(el.hasAttribute("data-algorithm")) return el; el = el.parentNode; } return null; } function nameFromVar(el) { return el.textContent.replace(/(\s|\xa0)+/g, " ").trim(); } function colorCountsFromContainer(container) { const namesFromColor = Array.from({length:COLOR_COUNT}, x=>new Set()); for(let v of container.querySelectorAll("var[data-var-color]")) { let color = +v.getAttribute("data-var-color"); namesFromColor[color].add(nameFromVar(v)); } return namesFromColor.map(x=>x.size); } function leastUsedColor(colors) { // Find the earliest color with the lowest count. let minCount = Infinity; let minColor = null; for(var i = 0; i < colors.length; i++) { if(colors[i] < minCount) { minColor = i; minCount = colors[i]; } } return minColor; } function chooseHighlightColor(container, v) { const colorCounts = colorCountsFromContainer(container); if(v.hasAttribute("data-var-last-color")) { let color = +v.getAttribute("data-var-last-color"); if(colorCounts[color] == 0) return color; } return leastUsedColor(colorCounts); } } </script> <script>/* Boilerplate: script-wpt */ "use strict"; { let wptData = { "paths": ["/css/css-variables/"], }; document.addEventListener("DOMContentLoaded", async ()=>{ if(wptData.paths.length == 0) return; const runsUrl = "https://wpt.fyi/api/runs?label=master&label=stable&max-count=1&product=chrome&product=firefox&product=safari&product=edge"; const runs = await (await fetch(runsUrl)).json(); let testResults = []; for(const pathPrefix of wptData.paths) { const pathResults = await (await fetch("https://wpt.fyi/api/search", { method:"POST", headers:{ "Content-Type":"application/json", }, body: JSON.stringify({ "run_ids": runs.map(x=>x.id), "query": {"path": pathPrefix}, }) })).json(); testResults = testResults.concat(pathResults.results); } const browsers = runs.map(x=>({name:x.browser_name, version:x.browser_version, passes:0, total: 0})); const resultsFromPath = new Map(testResults.map(result=>{ const testPath = result.test; const passes = result.legacy_status.map(x=>[x.passes, x.total]); return [testPath, passes]; })); const seenTests = new Set(); document.querySelectorAll(".wpt-name").forEach(nameEl=>{ const passData = resultsFromPath.get("/" + nameEl.getAttribute("title")); if(!passData) { console.log("Couldn't find test in results:", nameEl); return } const numTests = passData[0][1]; if(numTests > 1) { nameEl.insertAdjacentElement("beforeend", mk.small({}, ` (${numTests} tests)`)); } if(passData == undefined) return; const resultsEl = mk.span({"class":"wpt-results"}, ...passData.map((p,i) => mk.span( { "title": `${browsers[i].name} ${p[0]}/${p[1]}`, "class": "wpt-result", "style": `background: conic-gradient(forestgreen ${p[0]/p[1]*360}deg, darkred 0deg);`, })), ); nameEl.insertAdjacentElement("afterend", resultsEl); // Only update the summary pass/total count if we haven't seen this // test before, to support authors listing the same test multiple times // in a spec. if (!seenTests.has(nameEl.getAttribute("title"))) { seenTests.add(nameEl.getAttribute("title")); passData.forEach((p,i) => { browsers[i].passes += p[0]; browsers[i].total += p[1]; }); } }); const overview = document.querySelector(".wpt-overview"); if(overview) { overview.appendChild(mk.ul({}, ...browsers.map(formatWptResult))); document.head.appendChild(mk.style({}, `.wpt-overview ul { display: flex; flex-flow: row wrap; gap: .2em; justify-content: start; list-style: none; padding: 0; margin: 0;} .wpt-overview li { padding: .25em 1em; color: black; text-align: center; } .wpt-overview img { height: 1.5em; height: max(1.5em, 32px); background: transparent; } .wpt-overview .browser { font-weight: bold; } .wpt-overview .passes-none { background: #e57373; } .wpt-overview .passes-hardly { background: #ffb74d; } .wpt-overview .passes-a-few { background: #ffd54f; } .wpt-overview .passes-half { background: #fff176; } .wpt-overview .passes-lots { background: #dce775; } .wpt-overview .passes-most { background: #aed581; } .wpt-overview .passes-all { background: #81c784; }`)); } }); function formatWptResult({name, version, passes, total}) { const passRate = passes/total; let passClass = ""; if(passRate == 0) passClass = "passes-none"; else if(passRate < .2) passClass = "passes-hardly"; else if(passRate < .4) passClass = "passes-a-few"; else if(passRate < .6) passClass = "passes-half"; else if(passRate < .8) passClass = "passes-lots"; else if(passRate < 1) passClass = "passes-most"; else passClass = "passes-all"; name = name[0].toUpperCase() + name.slice(1); const shortVersion = /^\d+/.exec(version); const icon = [] if(name == "Chrome") icon.push(mk.img({alt:"", src:"https://wpt.fyi/static/chrome_64x64.png"})); if(name == "Edge") icon.push(mk.img({alt:"", src:"https://wpt.fyi/static/edge_64x64.png"})); if(name == "Safari") icon.push(mk.img({alt:"", src:"https://wpt.fyi/static/safari_64x64.png"})); if(name == "Firefox") icon.push(mk.img({alt:"", src:"https://wpt.fyi/static/firefox_64x64.png"})); return mk.li({"class":passClass}, mk.nobr({'class':'browser'}, ...icon, ` ${name} ${shortVersion}`), mk.br(), mk.nobr({'class':'pass-rate'}, `${passes}/${total}`) ); } } </script>