@@ -244,6 +244,51 @@ the computed value is one of the following:
244244 the computed value is the resolved absolute URL as described in [[!css3-values]] .
245245* otherwise, the computed value is as specified.
246246
247+ <details class=note>
248+ <summary> URL behavior examples</summary>
249+ <div class='example'>
250+ Because URLs resolve against the base URL of the stylesheet they appear in, we can
251+ end up with multiple relative URLs that resolve against different base URLs, even though
252+ they appear in the same property.
253+
254+ For example, suppose '--url-foo' and '--url-bar' are registered
255+ custom properties with ''<url>'' syntax, and that we have a stylesheet at
256+ <code> /style/foo/foo.css</code> :
257+
258+ <pre class='lang-css'>
259+ div {
260+ --url-foo: url("foo.png");
261+ }
262+ </pre>
263+
264+ and another stylesheet at <code> /style/bar/bar.css</code>
265+ <pre class='lang-css'>
266+ div {
267+ --url-bar: url("bar.png");
268+ }
269+ </pre>
270+
271+ and finally a document at <code> /index.html</code> :
272+ <pre class='lang-html'>
273+ <link href="/style/foo/foo.css" rel="stylesheet" type="text/css">
274+ <link href="/style/bar/bar.css" rel="stylesheet" type="text/css">
275+ <div style="background-image: var(--url-foo), var(---url-bar);">
276+ </div>
277+ </pre>
278+
279+ Here, the ''var(--url-foo)'' reference would produce a URL that resolves against
280+ <code> /style/foo</code> , and the ''var(--url-bar)'' reference would produce a URL that resolves
281+ against <code> /style/bar</code> .
282+
283+ On the other hand,
284+ if both '--url-foo' and '--url-bar' were <em> un</em> registered,
285+ they would substitute their literal values
286+ (relative URLs)
287+ into the <code> /index.html</code> stylesheet,
288+ which would then resolve the URLs against <code> /index.html</code> instead.
289+ </div>
290+ </details>
291+
247292For <code> "<image>"</code> values,
248293the computed value is the [=computed <image>=] .
249294
@@ -312,47 +357,6 @@ but be automatically [=invalid at computed-value time=].
312357As ''@supports'' tests parsing behavior,
313358it thus also accepts all values as valid regardless of the registered syntax.
314359
315- Relative URLs {#relative-urls}
316- ------------------------------
317-
318- Relative URL values that appear in registered custom properties are resolved
319- to full URLs as described in [[!css3-values]] .
320-
321- <div class='example'>
322- Because URLs resolve against the base URL of the stylesheet they appear in, we can
323- end up with multiple relative URLs that resolve against different base URLs, even though
324- they appear in the same property.
325-
326- For example, suppose '--url-foo' and '--url-bar' are registered
327- custom properties with ''<url>'' syntax, and that we have a stylesheet at
328- <code> /style/foo/foo.css</code> :
329-
330- <pre class='lang-css'>
331- div {
332- --url-foo: url("foo.png");
333- }
334- </pre>
335-
336- and another stylesheet at <code> /style/bar/bar.css</code>
337- <pre class='lang-css'>
338- div {
339- --url-bar: url("bar.png");
340- }
341- </pre>
342-
343- and finally a document at <code> /index.html</code> :
344- <pre class='lang-html'>
345- <link href="/style/foo/foo.css" rel="stylesheet" type="text/css">
346- <link href="/style/bar/bar.css" rel="stylesheet" type="text/css">
347- <div style="background-image: var(--url-foo), var(---url-bar);">
348- </div>
349- </pre>
350-
351- Here, the ''var(--url-foo)'' reference would produce a URL that resolves against
352- <code> /style/foo</code> , and the ''var(--url-bar)'' reference would produce a URL that resolves
353- against <code> /style/bar</code> .
354-
355- </div>
356360
357361Substitution via ''var()'' {#substitution}
358362------------------------------------------
0 commit comments