On this page
  1. var()
  2. Syntax & Overview
  3. Notes & Best Practices
  4. Example

var()

Prev: color | Up: color | Next: `oklch()`
Rel: color, Color & Value Functions Guide
Ref: MDN Web Docs — var()
Tags: #public #web #css #functions #color #tier/core


Syntax & Overview

var(--surface, #ffffff)

Substitutes a CSS custom property value with an optional fallback.

Notes & Best Practices

Example

:root { --radius: 8px; }
.card { border-radius: var(--card-radius, var(--radius)); }
.card--pill { --card-radius: 999px; }

Linked from

Related notes