A theme defines –space: 12px and a custom –fluid-gap(–min, –max) function. var(–space) substitutes the cascaded tokens directly. –fluid-gap(8px, 24px) enters the function’s declared scope, evaluates its calculation and returns a typed result. Both use names beginning with two dashes, yet their evaluation jobs differ.
This lesson continues The Gold Standard of Websites, the Gold Standard of Education and the How X Works hub. Every function, property, call site and computed-value trace is an original synthetic fixture. The lesson does not claim universal @function support, turn CSS into unrestricted script, bypass value grammar, guarantee recursion behavior or treat a draft syntax as a production baseline.
Record function name, definition scope and cascade layer, parameter declarations, argument tokens and types, inherited custom properties, local assignments, conditional branch, return value, call-site property grammar, computed result, error or fallback, browser build and unavailable behavior.
The CSS Custom Functions and Mixins Module Level 1 defines @function, parameters, local custom properties, conditionals and return results. The CSS Custom Properties for Cascading Variables Module defines custom-property values and var() substitution. The custom-functions module is an editor draft; syntax, support and observations are therefore dated.
THE GOLD STANDARD · WEBSITES
A custom property supplies tokens; a custom function executes a declared evaluation path
A custom property stores a cascaded token value that var() substitutes where referenced. A CSS custom function declared with @function accepts arguments, establishes parameters and local custom properties, evaluates conditional rules, and produces a result through its return descriptor. Calling a function can use custom properties, but substitution alone does not execute a function body.
Fast route
Start with the decisive rule.
Start this route
Measurement route
Build the browser state and evidence ledger.
Start this route
Comparison route
Separate the nearest lookalikes.
Start this route
Transfer route
Change the context and retest.
Start this route
Reporting route
State limits and continue reading.
Start this route
Chapter contents
Open the full chapter index
- 1. Give the execution-versus-substitution rule
- 2. Resolve the function definition
- 3. Bind parameters
- 4. Distinguish defaults from var fallbacks
- 5. Use local custom properties
- 6. Trace inherited call-site values
- 7. Evaluate conditions explicitly
- 8. Require a usable return
- 9. Separate invalid function from invalid property
- 10. Keep cascade and evaluation apart
- 11. Account for tree scope
- 12. Avoid script analogies
- 13. Test nested calls carefully
- 14. Treat recursion as a bounded specification question
- 15. Repair the double-dash shortcut
- 16. Answer practical questions
- 17. Create a reproducible evaluation ledger
- 18. Use the draft source and continue
1. Give the execution-versus-substitution rule
var() substitutes the value of a custom property. A custom function call resolves a definition, binds arguments, evaluates its body and returns a result.
Original worked example. gap:var(–space) receives 12px; gap:–fluid-gap(8px,24px) receives the function result after evaluation. The objects, values and observations are explicit so the reader can reconstruct the decision instead of trusting a label.
Changed-context transfer. Make the function return var(–space). Both mechanisms now appear in one path but remain identifiable. State what changed, predict the consequence and revise only the conclusion that depended on that condition.
Practical evidence check. Log substitution inputs, function steps and final property value. If this check fails, mark the claim unavailable and repair the method before continuing.
Keep declared input, resolved platform state and final claim in separate fields so a matching screenshot cannot rewrite the mechanism.
Before closing, reconcile the original fixture against the chapter rule: identify the relevant objects, state, event order or geometry and the first missing obligation; change one condition and mark the first unsupported inference. Preserve the raw trace beside the revised result. End the chapter with three sentences: what the evidence establishes, what it does not establish and what observation would change the conclusion. This keeps the lesson useful when the browser, document or platform state changes. A strong record also names the datum, denominator, section or coordinate system that governed the decision, so a later reader can repeat the reasoning without importing an unstated shortcut.
2. Resolve the function definition
A function call must match a visible @function definition under the draft’s scoping rules. A similarly named custom property is not that definition.
Original worked example. –tone exists both as a property and as a function name in separate syntactic roles. The objects, values and observations are explicit so the reader can reconstruct the decision instead of trusting a label.
Changed-context transfer. Remove the @function rule while keeping the property. State what changed, predict the consequence and revise only the conclusion that depended on that condition.
Practical evidence check. Record definition lookup and support status. If this check fails, mark the claim unavailable and repair the method before continuing.
Use a positive case, a clean negative case and an unavailable case. Unavailable means the required support or evidence was not established.
Before closing, reconcile the original fixture against the chapter rule: identify the relevant objects, state, event order or geometry and the first missing obligation; change one condition and mark the first unsupported inference. Preserve the raw trace beside the revised result. End the chapter with three sentences: what the evidence establishes, what it does not establish and what observation would change the conclusion. This keeps the lesson useful when the browser, document or platform state changes. A strong record also names the datum, denominator, section or coordinate system that governed the decision, so a later reader can repeat the reasoning without importing an unstated shortcut.
Previous chapter · Contents · Next chapter
3. Bind parameters
Parameters receive call arguments according to their declared forms and optional type expectations. They are local inputs, not globally cascaded declarations.
Original worked example. –clamp-gap(–lo, –hi) binds 8px and 24px for one call and 4px and 12px for another. The objects, values and observations are explicit so the reader can reconstruct the decision instead of trusting a label.
Changed-context transfer. Swap arguments and predict the branch outcome. State what changed, predict the consequence and revise only the conclusion that depended on that condition.
Practical evidence check. Store argument order, tokens and parameter values. If this check fails, mark the claim unavailable and repair the method before continuing.
Change one consequential premise while keeping the rest fixed. Predict the new branch before inspecting it and preserve disagreement.
Before closing, reconcile the original fixture against the chapter rule: identify the relevant objects, state, event order or geometry and the first missing obligation; change one condition and mark the first unsupported inference. Preserve the raw trace beside the revised result. End the chapter with three sentences: what the evidence establishes, what it does not establish and what observation would change the conclusion. This keeps the lesson useful when the browser, document or platform state changes. A strong record also names the datum, denominator, section or coordinate system that governed the decision, so a later reader can repeat the reasoning without importing an unstated shortcut.
Previous chapter · Contents · Next chapter
4. Distinguish defaults from var fallbacks
A function parameter default belongs to function argument binding. The second argument of var() is used when custom-property substitution requires a fallback.
Original worked example. Omitting –hi uses the function’s declared default; var(–theme-gap, 1rem) handles a missing property. The objects, values and observations are explicit so the reader can reconstruct the decision instead of trusting a label.
Changed-context transfer. Provide an invalid call argument and a missing custom property separately. State what changed, predict the consequence and revise only the conclusion that depended on that condition.
Practical evidence check. Name which fallback mechanism was reached. If this check fails, mark the claim unavailable and repair the method before continuing.
Carry one plausible alternative through the ledger, then choose the next observation that separates it from the leading account.
Before closing, reconcile the original fixture against the chapter rule: identify the relevant objects, state, event order or geometry and the first missing obligation; change one condition and mark the first unsupported inference. Preserve the raw trace beside the revised result. End the chapter with three sentences: what the evidence establishes, what it does not establish and what observation would change the conclusion. This keeps the lesson useful when the browser, document or platform state changes. A strong record also names the datum, denominator, section or coordinate system that governed the decision, so a later reader can repeat the reasoning without importing an unstated shortcut.
Previous chapter · Contents · Next chapter
5. Use local custom properties
A function body can assign local custom properties used during evaluation. Those locals do not become declarations on the calling element.
Original worked example. The body computes –range from its parameters and returns calc(var(–lo) + var(–range)/2). The objects, values and observations are explicit so the reader can reconstruct the decision instead of trusting a label.
Changed-context transfer. Inspect the element outside the function for –range. State what changed, predict the consequence and revise only the conclusion that depended on that condition.
Practical evidence check. Record scope and where each name resolves. If this check fails, mark the claim unavailable and repair the method before continuing.
Name the relevant element, box, option, container, scope, value or event. Similar visible results can come from different paths.
Before closing, reconcile the original fixture against the chapter rule: identify the relevant objects, state, event order or geometry and the first missing obligation; change one condition and mark the first unsupported inference. Preserve the raw trace beside the revised result. End the chapter with three sentences: what the evidence establishes, what it does not establish and what observation would change the conclusion. This keeps the lesson useful when the browser, document or platform state changes. A strong record also names the datum, denominator, section or coordinate system that governed the decision, so a later reader can repeat the reasoning without importing an unstated shortcut.
Previous chapter · Contents · Next chapter
6. Trace inherited call-site values
Function evaluation can refer to custom properties available from the call-site context under the draft model. The result can therefore vary between elements with the same arguments.
Original worked example. Two cards call –accent-mix(40%) but inherit different –brand colors. The objects, values and observations are explicit so the reader can reconstruct the decision instead of trusting a label.
Changed-context transfer. Set the same –brand on their common ancestor. State what changed, predict the consequence and revise only the conclusion that depended on that condition.
Practical evidence check. Capture call arguments, inherited values and results. If this check fails, mark the claim unavailable and repair the method before continuing.
Archive source, fixture, declarations, state, events, browser version and raw exceptions so another reader can reproduce the conclusion.
Before closing, reconcile the original fixture against the chapter rule: identify the relevant objects, state, event order or geometry and the first missing obligation; change one condition and mark the first unsupported inference. Preserve the raw trace beside the revised result. End the chapter with three sentences: what the evidence establishes, what it does not establish and what observation would change the conclusion. This keeps the lesson useful when the browser, document or platform state changes. A strong record also names the datum, denominator, section or coordinate system that governed the decision, so a later reader can repeat the reasoning without importing an unstated shortcut.
Previous chapter · Contents · Next chapter
7. Evaluate conditions explicitly
Conditional rules inside a function choose a return path from declared tests. A function name does not imply a branch.
Original worked example. A spacing function returns 0 for a compact mode and a calculated value otherwise. The objects, values and observations are explicit so the reader can reconstruct the decision instead of trusting a label.
Changed-context transfer. Change only the mode custom property. State what changed, predict the consequence and revise only the conclusion that depended on that condition.
Practical evidence check. Log condition inputs, matched branch and result. If this check fails, mark the claim unavailable and repair the method before continuing.
Keep declared input, resolved platform state and final claim in separate fields so a matching screenshot cannot rewrite the mechanism.
Before closing, reconcile the original fixture against the chapter rule: identify the relevant objects, state, event order or geometry and the first missing obligation; change one condition and mark the first unsupported inference. Preserve the raw trace beside the revised result. End the chapter with three sentences: what the evidence establishes, what it does not establish and what observation would change the conclusion. This keeps the lesson useful when the browser, document or platform state changes. A strong record also names the datum, denominator, section or coordinate system that governed the decision, so a later reader can repeat the reasoning without importing an unstated shortcut.
Previous chapter · Contents · Next chapter
8. Require a usable return
A custom function must produce a result that the calling property can accept. Successful function evaluation does not override the grammar of color, length or other properties.
Original worked example. A function returns 14px for gap and works; returning red makes the gap declaration invalid. The objects, values and observations are explicit so the reader can reconstruct the decision instead of trusting a label.
Changed-context transfer. Call the same color-producing function from color. State what changed, predict the consequence and revise only the conclusion that depended on that condition.
Practical evidence check. Record function result type and call-site grammar. If this check fails, mark the claim unavailable and repair the method before continuing.
Use a positive case, a clean negative case and an unavailable case. Unavailable means the required support or evidence was not established.
Before closing, reconcile the original fixture against the chapter rule: identify the relevant objects, state, event order or geometry and the first missing obligation; change one condition and mark the first unsupported inference. Preserve the raw trace beside the revised result. End the chapter with three sentences: what the evidence establishes, what it does not establish and what observation would change the conclusion. This keeps the lesson useful when the browser, document or platform state changes. A strong record also names the datum, denominator, section or coordinate system that governed the decision, so a later reader can repeat the reasoning without importing an unstated shortcut.
Previous chapter · Contents · Next chapter
9. Separate invalid function from invalid property
An undefined function, bad argument or missing return can fail at a different stage from a valid returned value that is invalid for the property.
Original worked example. Case A cannot resolve the function; Case B resolves to 20deg for width. The objects, values and observations are explicit so the reader can reconstruct the decision instead of trusting a label.
Changed-context transfer. Add a valid width return without changing lookup. State what changed, predict the consequence and revise only the conclusion that depended on that condition.
Practical evidence check. Identify the first failing obligation. If this check fails, mark the claim unavailable and repair the method before continuing.
Change one consequential premise while keeping the rest fixed. Predict the new branch before inspecting it and preserve disagreement.
Before closing, reconcile the original fixture against the chapter rule: identify the relevant objects, state, event order or geometry and the first missing obligation; change one condition and mark the first unsupported inference. Preserve the raw trace beside the revised result. End the chapter with three sentences: what the evidence establishes, what it does not establish and what observation would change the conclusion. This keeps the lesson useful when the browser, document or platform state changes. A strong record also names the datum, denominator, section or coordinate system that governed the decision, so a later reader can repeat the reasoning without importing an unstated shortcut.
Previous chapter · Contents · Next chapter
10. Keep cascade and evaluation apart
The cascade selects declarations and custom-property values before or during computed-value processing; function evaluation uses the resulting context. It does not replace cascade ordering.
Original worked example. Two layers supply –scale, and the winning value is used inside a function. The objects, values and observations are explicit so the reader can reconstruct the decision instead of trusting a label.
Changed-context transfer. Swap layer precedence while keeping the function definition. State what changed, predict the consequence and revise only the conclusion that depended on that condition.
Practical evidence check. Archive candidates, winner and evaluated result. If this check fails, mark the claim unavailable and repair the method before continuing.
Carry one plausible alternative through the ledger, then choose the next observation that separates it from the leading account.
Before closing, reconcile the original fixture against the chapter rule: identify the relevant objects, state, event order or geometry and the first missing obligation; change one condition and mark the first unsupported inference. Preserve the raw trace beside the revised result. End the chapter with three sentences: what the evidence establishes, what it does not establish and what observation would change the conclusion. This keeps the lesson useful when the browser, document or platform state changes. A strong record also names the datum, denominator, section or coordinate system that governed the decision, so a later reader can repeat the reasoning without importing an unstated shortcut.
Previous chapter · Contents · Next chapter
11. Account for tree scope
Definitions and custom properties can be subject to document and shadow-tree scope. A working call in one component does not prove visibility in another.
Original worked example. A function is declared in a component scope and called inside and outside it. The objects, values and observations are explicit so the reader can reconstruct the decision instead of trusting a label.
Changed-context transfer. Move the call across the shadow boundary. State what changed, predict the consequence and revise only the conclusion that depended on that condition.
Practical evidence check. Record root, scope and lookup result. If this check fails, mark the claim unavailable and repair the method before continuing.
Name the relevant element, box, option, container, scope, value or event. Similar visible results can come from different paths.
Before closing, reconcile the original fixture against the chapter rule: identify the relevant objects, state, event order or geometry and the first missing obligation; change one condition and mark the first unsupported inference. Preserve the raw trace beside the revised result. End the chapter with three sentences: what the evidence establishes, what it does not establish and what observation would change the conclusion. This keeps the lesson useful when the browser, document or platform state changes. A strong record also names the datum, denominator, section or coordinate system that governed the decision, so a later reader can repeat the reasoning without importing an unstated shortcut.
Previous chapter · Contents · Next chapter
12. Avoid script analogies
CSS custom functions are declarative value mechanisms defined by CSS evaluation, not general JavaScript functions with arbitrary side effects.
Original worked example. A function calculates a responsive length and cannot fetch data or mutate the DOM. The objects, values and observations are explicit so the reader can reconstruct the decision instead of trusting a label.
Changed-context transfer. Replace the requirement with a DOM update. State what changed, predict the consequence and revise only the conclusion that depended on that condition.
Practical evidence check. Choose the platform mechanism from the required effect. If this check fails, mark the claim unavailable and repair the method before continuing.
Archive source, fixture, declarations, state, events, browser version and raw exceptions so another reader can reproduce the conclusion.
Before closing, reconcile the original fixture against the chapter rule: identify the relevant objects, state, event order or geometry and the first missing obligation; change one condition and mark the first unsupported inference. Preserve the raw trace beside the revised result. End the chapter with three sentences: what the evidence establishes, what it does not establish and what observation would change the conclusion. This keeps the lesson useful when the browser, document or platform state changes. A strong record also names the datum, denominator, section or coordinate system that governed the decision, so a later reader can repeat the reasoning without importing an unstated shortcut.
Previous chapter · Contents · Next chapter
13. Test nested calls carefully
A function result or body can involve another custom function where permitted. Nested evaluation needs a trace; it is not one opaque label.
Original worked example. –card-gap() calls –scale-space() with a local parameter and returns the nested result. The objects, values and observations are explicit so the reader can reconstruct the decision instead of trusting a label.
Changed-context transfer. Break the inner definition only. State what changed, predict the consequence and revise only the conclusion that depended on that condition.
Practical evidence check. Log call stack, parameters and first failure. If this check fails, mark the claim unavailable and repair the method before continuing.
Keep declared input, resolved platform state and final claim in separate fields so a matching screenshot cannot rewrite the mechanism.
Before closing, reconcile the original fixture against the chapter rule: identify the relevant objects, state, event order or geometry and the first missing obligation; change one condition and mark the first unsupported inference. Preserve the raw trace beside the revised result. End the chapter with three sentences: what the evidence establishes, what it does not establish and what observation would change the conclusion. This keeps the lesson useful when the browser, document or platform state changes. A strong record also names the datum, denominator, section or coordinate system that governed the decision, so a later reader can repeat the reasoning without importing an unstated shortcut.
Previous chapter · Contents · Next chapter
14. Treat recursion as a bounded specification question
Do not assume recursive calls work like a programming language or terminate safely. Use the draft’s rules and avoid unsupported cycles.
Original worked example. A nonrecursive scale function handles three branches explicitly. The objects, values and observations are explicit so the reader can reconstruct the decision instead of trusting a label.
Changed-context transfer. Replace one branch with a self-call and mark behavior unavailable until the rule and support are established. State what changed, predict the consequence and revise only the conclusion that depended on that condition.
Practical evidence check. Detect cycles and preserve the exact definition. If this check fails, mark the claim unavailable and repair the method before continuing.
Use a positive case, a clean negative case and an unavailable case. Unavailable means the required support or evidence was not established.
Before closing, reconcile the original fixture against the chapter rule: identify the relevant objects, state, event order or geometry and the first missing obligation; change one condition and mark the first unsupported inference. Preserve the raw trace beside the revised result. End the chapter with three sentences: what the evidence establishes, what it does not establish and what observation would change the conclusion. This keeps the lesson useful when the browser, document or platform state changes. A strong record also names the datum, denominator, section or coordinate system that governed the decision, so a later reader can repeat the reasoning without importing an unstated shortcut.
Previous chapter · Contents · Next chapter
15. Repair the double-dash shortcut
Names beginning with two dashes appear in custom properties, parameters and function names under different grammars. Prefix shape alone does not identify semantics.
Original worked example. A code review labels each occurrence as declaration, var reference, parameter or call. The objects, values and observations are explicit so the reader can reconstruct the decision instead of trusting a label.
Changed-context transfer. Remove punctuation context and observe the ambiguity. State what changed, predict the consequence and revise only the conclusion that depended on that condition.
Practical evidence check. Parse the containing grammar before naming the mechanism. If this check fails, mark the claim unavailable and repair the method before continuing.
Change one consequential premise while keeping the rest fixed. Predict the new branch before inspecting it and preserve disagreement.
Before closing, reconcile the original fixture against the chapter rule: identify the relevant objects, state, event order or geometry and the first missing obligation; change one condition and mark the first unsupported inference. Preserve the raw trace beside the revised result. End the chapter with three sentences: what the evidence establishes, what it does not establish and what observation would change the conclusion. This keeps the lesson useful when the browser, document or platform state changes. A strong record also names the datum, denominator, section or coordinate system that governed the decision, so a later reader can repeat the reasoning without importing an unstated shortcut.
Previous chapter · Contents · Next chapter
16. Answer practical questions
Use custom properties for cascaded reusable values and use custom functions when a supported declarative computation with arguments and a return genuinely reduces duplication. Provide a plain fallback for unsupported environments.
Original worked example. A design system uses properties for tokens and a function for bounded fluid spacing. The objects, values and observations are explicit so the reader can reconstruct the decision instead of trusting a label.
Changed-context transfer. Change the computation to one fixed token. State what changed, predict the consequence and revise only the conclusion that depended on that condition.
Practical evidence check. Prefer the simpler mechanism that meets the reader job. If this check fails, mark the claim unavailable and repair the method before continuing.
Carry one plausible alternative through the ledger, then choose the next observation that separates it from the leading account.
Before closing, reconcile the original fixture against the chapter rule: identify the relevant objects, state, event order or geometry and the first missing obligation; change one condition and mark the first unsupported inference. Preserve the raw trace beside the revised result. End the chapter with three sentences: what the evidence establishes, what it does not establish and what observation would change the conclusion. This keeps the lesson useful when the browser, document or platform state changes. A strong record also names the datum, denominator, section or coordinate system that governed the decision, so a later reader can repeat the reasoning without importing an unstated shortcut.
Previous chapter · Contents · Next chapter
17. Create a reproducible evaluation ledger
A complete fixture preserves definitions, layers, scopes, arguments, locals, branches, returns, computed values and invalid cases.
Original worked example. The matrix covers direct var(), one function, call-site inheritance, nested calls and missing support. The objects, values and observations are explicit so the reader can reconstruct the decision instead of trusting a label.
Changed-context transfer. Repeat across light and shadow roots. State what changed, predict the consequence and revise only the conclusion that depended on that condition.
Practical evidence check. Version the editor draft, browser and feature flags. If this check fails, mark the claim unavailable and repair the method before continuing.
Name the relevant element, box, option, container, scope, value or event. Similar visible results can come from different paths.
Before closing, reconcile the original fixture against the chapter rule: identify the relevant objects, state, event order or geometry and the first missing obligation; change one condition and mark the first unsupported inference. Preserve the raw trace beside the revised result. End the chapter with three sentences: what the evidence establishes, what it does not establish and what observation would change the conclusion. This keeps the lesson useful when the browser, document or platform state changes. A strong record also names the datum, denominator, section or coordinate system that governed the decision, so a later reader can repeat the reasoning without importing an unstated shortcut.
Previous chapter · Contents · Next chapter
18. Use the draft source and continue
CSS Custom Functions and Mixins defines the emerging function model; CSS Variables and existing value-stage lessons define adjacent substitution and validity jobs.
Original worked example. The grouped route keeps cascade, substitution, evaluation and property grammar separate. The objects, values and observations are explicit so the reader can reconstruct the decision instead of trusting a label.
Changed-context transfer. When syntax or scoping changes, rerun binding, local, branch, return and fallback cases. State what changed, predict the consequence and revise only the conclusion that depended on that condition.
Practical evidence check. Save exact source anchors, access date and raw computed styles. If this check fails, mark the claim unavailable and repair the method before continuing.
Archive source, fixture, declarations, state, events, browser version and raw exceptions so another reader can reproduce the conclusion.
Before closing, reconcile the original fixture against the chapter rule: identify the relevant objects, state, event order or geometry and the first missing obligation; change one condition and mark the first unsupported inference. Preserve the raw trace beside the revised result. End the chapter with three sentences: what the evidence establishes, what it does not establish and what observation would change the conclusion. This keeps the lesson useful when the browser, document or platform state changes. A strong record also names the datum, denominator, section or coordinate system that governed the decision, so a later reader can repeat the reasoning without importing an unstated shortcut.
Grouped reading routes
Core route
Companion lessons
- Separating interpolate-size Keyword Permission from calc-size() Intrinsic-Size Calculation
- Separating reading-flow Navigation Order from CSS Visual Order
- Separating selectedcontent Display Cloning from Select Option Selection
Related specialist lessons
Sources and further study
CSS Custom Functions and Mixins Level 1. Used for the standard definitions, material mechanisms or method limits developed in this lesson.
CSS Custom Functions section. Used for the standard definitions, material mechanisms or method limits developed in this lesson.
CSS Custom Properties for Cascading Variables Level 1. Used for the standard definitions, material mechanisms or method limits developed in this lesson.
The worked examples and transfer checks are developed here and state their own assumptions. The linked sources support the underlying web-platform mechanisms, state and method limits.
Return to contents · Return to The Gold Standard of Websites