Skip to content

Commit bcd9a90

Browse files
committed
[css-variables-1][editorial] Add note calling out how things don't resolve in variables until they're subbed, talking about URLs explicitly. #757
1 parent 320541b commit bcd9a90

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

css-variables-1/Overview.bs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,24 @@ Custom Property Value Syntax</h3>
311311
which user agents can take advantage of by "canonicalizing" them into a single casing,
312312
but that isn't allowed for custom properties.)
313313

314+
<div class=note>
315+
Because custom properties can contain <em>anything</em>,
316+
there is no general way to know how to interpret what's inside of them
317+
(until they're substituted into a known property with ''var()'').
318+
Rather than have them <em>partially</em> resolve in some cases but not others,
319+
they're left completely unresolved;
320+
they're a bare stream of [[css-syntax#tokenization|CSS tokens]] interspersed with ''var()'' functions.
321+
322+
This has some knock-on implications.
323+
For example, relative URLs in CSS
324+
are resolved against the base URL of the stylesheet the value appears in.
325+
However, if a custom property like ''--my-image: url(foo.jpg);'' shows up in an <code>"/a/style.css"</code> stylesheet,
326+
it will not resolve into an absolute URL immediately;
327+
if that variable is later used in a <em>different</em> <code>"/b/style.css"</code> stylesheet
328+
like ''background: var(--my-image);'',
329+
it will resolve <em>at that point</em> to <code>"/b/foo.jpg"</code>.
330+
</div>
331+
314332
<h3 id='guaranteed-invalid'>
315333
Guaranteed-Invalid Values</h3>
316334

0 commit comments

Comments
 (0)