What values can you put in a CSS Custom Property?

Will Boyd:

CSS custom properties can hold all sorts of things. Some of these things were not obvious to me, which is why I decided to write this.

In short: they can contain just about everything. It’s only until CSS Custom Properties are used in a certain context as a CSS Variable — using var() — that they are evaluated.

☝️ To understand the above you should know that CSS Custom Properties are not Variables

A CSS Custom Property allows you to define a property with a certain value, e.g. --width: 200;.

It’s only when it’s used with var() — e.g. var(--width) — that you are creating a CSS Variable to use.

That’s why you can use CSS Custom Properties to:

What Can You Put in a CSS Variable? →

Published by Bramus!

Bramus is a frontend web developer from Belgium, working as a Chrome Developer Relations Engineer at Google. From the moment he discovered view-source at the age of 14 (way back in 1997), he fell in love with the web and has been tinkering with it ever since (more …)

Join the Conversation

1 Comment

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.