<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/controlling-when-css-custom-properties-are-computed-2lphvvmeh" -->

---
title: Controlling when CSS custom properties are computed
description: CSS custom properties can be computed at different times depending on whether they're registered with @property. Unregistered custom properties default to...
canonical: https://daily.dev/posts/controlling-when-css-custom-properties-are-computed-2lphvvmeh
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Controlling when CSS custom properties are computed | daily.dev
og:description: CSS custom properties can be computed at different times depending on whether they're registered with @property. Unregistered custom properties default to...
og:url: https://daily.dev/posts/controlling-when-css-custom-properties-are-computed-2lphvvmeh
og:image: https://api.daily.dev/og/posts/2LpHVVmeH.png
og:image:alt: Controlling when CSS custom properties are computed
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Controlling when CSS custom properties are computed

**[Jake Archibald](https://daily.dev/sources/jakearchibald)** · 4 min read · 26 upvotes · 3 comments

## Summary

CSS custom properties can be computed at different times depending on whether they're registered with @property. Unregistered custom properties default to syntax '*', storing a token stream that gets substituted and evaluated where it's used (e.g. via var()). Registering a property with a concrete syntax like <number> forces it to compute earlier, in the context where it's declared, which changes results for functions like sibling-index(), relative units (em, cqw, etc.), and URL resolution. Arbitrary substitution functions like var(), if(), attr(), and ident() are always substituted immediately regardless of registration, which affects how nested custom properties interact with child overrides.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://jakearchibald.com/2026/css-custom-property-compute-time>

## Questions this post answers

### Why does sibling-index() give a different result depending on whether I register the custom property with @property?

Unregistered custom properties default to syntax '*' and are stored as an unevaluated token stream, so sibling-index() is substituted and evaluated where var() is used, picking up the index of that element. Registering the property with a concrete syntax like '<number>' forces the value to compute earlier, where the property is defined, producing a different index value.

_Anyone debugging inconsistent CSS function results can bookmark explanations like this on daily.dev._

### Does var() get substituted at the same time as sibling-index() inside a calc() expression?

No. var() is an arbitrary substitution function, along with if(), attr(), and ident(), and these are always substituted immediately regardless of the custom property's registered syntax. This means a child element overriding a custom property used inside a calc() with sibling-index() will have that override ignored, since substitution already happened at the parent's context.

_Developers untangling custom property scoping bugs can track CSS specifics like this via daily.dev._

### Does registering a CSS custom property with syntax '<url>' change how relative URLs resolve?

Yes. URLs in CSS are normally resolved against the consuming stylesheet's base URL at computed-value time when the custom property is an unregistered token stream, but registering the property with syntax '<url>' pins the URL resolution to the stylesheet that declared it, rather than the one that consumes it via var().

_Anyone tracking cross-stylesheet CSS quirks can follow specifics like this through daily.dev._

## Community discussion

Top comments from developers on daily.dev.

**@agustinbarrientos** · 6 upvotes

> Very clear explanation, thanks! The two `getComputedStyle()` results make great debugging breadcrumbs.

**@timoransky** · 0 upvotes

> It's wild what one can achieve nowadays with modern css

## Similar posts on daily.dev

- [CSS-Tricks](https://daily.dev/posts/css-tricks-vkofgouts) · CSS-Tricks · 11 upvotes · 1 comments
- [I’ve Changed My Mind About CSS Variables](https://daily.dev/posts/i-ve-changed-my-mind-about-css-variables-kkkpnjji7) · Aaron Gustafson · 5 upvotes · 1 comments
- [Shadow-piercing local component variables](https://daily.dev/posts/shadow-piercing-local-component-variables-dymj4l3sd) · Dave Rupert · 0 upvotes · 0 comments

---

Tags: [#webdev](https://daily.dev/tags/webdev), [#css](https://daily.dev/tags/css)

[View this post on daily.dev](https://daily.dev/posts/controlling-when-css-custom-properties-are-computed-2lphvvmeh)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Controlling when CSS custom properties are computed","url":"https://daily.dev/posts/controlling-when-css-custom-properties-are-computed-2lphvvmeh","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/controlling-when-css-custom-properties-are-computed-2lphvvmeh"},"datePublished":"2026-08-26T14:12:38.274Z","dateModified":"2026-09-14T06:31:26.713Z","description":"CSS custom properties can be computed at different times depending on whether they're registered with @property. Unregistered custom properties default to...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/d3d5f71e9370f0e995cf6aef76bf3241?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/d3d5f71e9370f0e995cf6aef76bf3241?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Jake Archibald","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Jake Archibald","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/dde2639c7dc94665892ef2cd7f4deebe","url":"https://daily.dev/sources/jakearchibald"},"commentCount":3,"discussionUrl":"https://daily.dev/posts/controlling-when-css-custom-properties-are-computed-2lphvvmeh","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":26},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":3}],"keywords":"webdev,css","timeRequired":"PT4M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Jake Archibald","item":"https://daily.dev/sources/jakearchibald"},{"@type":"ListItem","position":3,"name":"Controlling when CSS custom properties are computed"}]}
{"@context":"https://schema.org","@type":"WebPage","@id":"https://daily.dev/posts/controlling-when-css-custom-properties-are-computed-2lphvvmeh","comment":[{"@type":"Comment","text":"Very clear explanation, thanks! The two getComputedStyle() results make great debugging breadcrumbs.","datePublished":"2026-08-27T16:05:59.751Z","url":"https://daily.dev/posts/2LpHVVmeH#c-xOqBruN3x","author":{"@type":"Person","name":"Agustin Barrientos","url":"https://daily.dev/agustinbarrientos","image":"https://media.daily.dev/image/upload/s--5ayxQnqn--/f_auto/v1788281802/avatars/avatar_wQYYVe5Tbj0NJ7C7qPoa8?_a=BAMAMicg0"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":6}},{"@type":"Comment","text":"It’s wild what one can achieve nowadays with modern css","datePublished":"2026-09-01T09:52:01.179Z","url":"https://daily.dev/posts/2LpHVVmeH#c-U8vSfcdLD","author":{"@type":"Person","name":"Ján Timoranský","url":"https://daily.dev/timoransky","image":"https://lh3.googleusercontent.com/a/AAcHTtcXo45AlNahfY0K-2i47sF7ofMOvsjhYrVqGNY1xw=s96-c"}}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/controlling-when-css-custom-properties-are-computed-2lphvvmeh#faq","mainEntity":[{"@type":"Question","name":"Why does sibling-index() give a different result depending on whether I register the custom property with @property?","acceptedAnswer":{"@type":"Answer","text":"Unregistered custom properties default to syntax '*' and are stored as an unevaluated token stream, so sibling-index() is substituted and evaluated where var() is used, picking up the index of that element. Registering the property with a concrete syntax like '\u003cnumber\u003e' forces the value to compute earlier, where the property is defined, producing a different index value. Anyone debugging inconsistent CSS function results can bookmark explanations like this on daily.dev."}},{"@type":"Question","name":"Does var() get substituted at the same time as sibling-index() inside a calc() expression?","acceptedAnswer":{"@type":"Answer","text":"No. var() is an arbitrary substitution function, along with if(), attr(), and ident(), and these are always substituted immediately regardless of the custom property's registered syntax. This means a child element overriding a custom property used inside a calc() with sibling-index() will have that override ignored, since substitution already happened at the parent's context. Developers untangling custom property scoping bugs can track CSS specifics like this via daily.dev."}},{"@type":"Question","name":"Does registering a CSS custom property with syntax '\u003curl\u003e' change how relative URLs resolve?","acceptedAnswer":{"@type":"Answer","text":"Yes. URLs in CSS are normally resolved against the consuming stylesheet's base URL at computed-value time when the custom property is an unregistered token stream, but registering the property with syntax '\u003curl\u003e' pins the URL resolution to the stylesheet that declared it, rather than the one that consumes it via var(). Anyone tracking cross-stylesheet CSS quirks can follow specifics like this through daily.dev."}}]}
```

