← All notes

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

Sources

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

Permanent ID: iil:note:59n4gv6z

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.},
}

Markdown

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.

All artifact files (JSON index)

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.