CSS custom properties: reusable values with var()
Answer: CSS custom properties, often called CSS variables, hold reusable values under names that start with two dashes. Use the var() function to read a value.
Defining and using a property
Custom properties, or CSS variables, allow you to organize and reuse values in your CSS.
The var() function is how you use the value of a custom property.
You can use the var() function in values. You cannot use the var() function in media queries.
Naming and substitution
CSS variables are more accurately known as CSS custom properties.
Two dashes begin every custom property name.
When var() runs, it retrieves the stored value and replaces itself with that value.
See also
Claims
- id: C1 claim: Custom properties, or CSS variables, let you organize and reuse values. source: S1 evidence: "Custom properties, or CSS variables, allow you to organize and reuse values"
- id: C2 claim: var() can be used in values, but not in media queries. source: S1 evidence: "in values, but not in media queries"
- id: C3 claim: CSS variables are more accurately known as CSS custom properties. source: S2 evidence: "more accurately known as CSS custom properties"
- id: C4 claim: All custom properties begin with two dashes. source: S2 evidence: "all custom properties begin with two dashes"
Sources
- [S1] Custom properties. web.dev. https://web.dev/learn/css/custom-properties . License: CC-BY-4.0. Accessed 2026-11-23.
- [S2] CSS Variables - Why should you care?. Chrome for Developers. https://developer.chrome.com/blog/css-variables-why-should-you-care . License: CC-BY-4.0. Accessed 2026-11-23.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: web.dev, Custom properties; Chrome for Developers, CSS Variables - Why should you care?. CC-BY-4.0 (https://web.dev/learn/css/flexbox). Copyright Google LLC. web.dev text is CC BY 4.0. CC-BY-4.0 (https://developers.google.com/site-policies). Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License. Copyright Google LLC. Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: web.dev, Custom properties; Chrome for Developers, CSS Variables - Why should you care?. CC-BY-4.0 (https://web.dev/learn/css/flexbox). Copyright Google LLC. web.dev text is CC BY 4.0. CC-BY-4.0 (https://developers.google.com/site-policies). Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License. Copyright Google LLC.
Cite this
iinventedlight. 2026. "CSS custom properties: reusable values with var()." iinventedlight Library, iil:note:59n4gv6z, version of 2026-11-23. https://iinventedlight.com/library/notes/css-custom-properties/. License: CC-BY-4.0.
@misc{iil_note_59n4gv6z,
author = {{iinventedlight}},
title = {{CSS custom properties: reusable values with var()}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-23},
url = {https://iinventedlight.com/library/notes/css-custom-properties/},
note = {Permanent ID iil:note:59n4gv6z. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
Extra files beside this note
These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.
- css-custom-properties.schema.json (schema; CC-BY-4.0)
- css-custom-properties.table.json (table; CC-BY-4.0)
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/css-custom-properties.md.