Skip to main content
CSS-Tricks
  • Articles
  • Notes
  • Links
  • Guides
  • Almanac
  • Picks
  • Shuffle
Search

Articles Tagged
custom properties

91 Articles
Direct link to the article Maybe don’t use custom properties in shorthand properties
cascade custom properties

Maybe don’t use custom properties in shorthand properties

This easily qualifies as a "gotcha" in CSS and is a good reminder that the cascade doesn't know everything all at the same time. If a custom property is invalid, the cascade won't ignore it, and it gets evaluated, which invalidates the declaration.
Geoff Graham on Mar 6, 2025
Direct link to the article Calculate Viewport Size in CSS
custom properties functions viewport units

Calculate Viewport Size in CSS

A way to calculate the viewport’s width and height without JavaScript, by way of Temani Afif over at CSS Tip:

@property --_w {
  syntax: '<length';
  inherits: true;
  initial-value: 100vw; 
}
@property --_h {
  syntax: '<length';
  inherits: true;
  
…
Geoff Graham on Jul 17, 2024
Direct link to the article “If” CSS Gets Inline Conditionals
custom properties selectors

“If” CSS Gets Inline Conditionals

A few sirens went off a couple of weeks ago when the CSS Working Group (CSSWG) resolved to add an if() conditional to the CSS Values Module Level 5 specification. It was Lea Verou’s X post that same day that …

Geoff Graham on Jul 19, 2024
Direct link to the article How I Made an Icon System Out of CSS Custom Properties
custom properties Sass SVG svg icons

How I Made an Icon System Out of CSS Custom Properties

SVG is the best format for icons on a website, there is no doubt about that. It allows you to have sharp icons no matter the screen pixel density, you can change the styles of the SVG on hover …

Louis Hoebregts on Sep 28, 2022
Direct link to the article Making a Real-Time Clock With a Conic Gradient Face
conic gradients custom properties dates gradients

Making a Real-Time Clock With a Conic Gradient Face

Gradients have been a part of the CSS spectrum for quite some time now. We see a lot of radial and linear gradients in a lot of projects, but there is one type of gradient that seems to be a …

Brecht De Ruyte on Sep 19, 2022
Direct link to the article Interpolating Numeric CSS Variables
@property animation custom properties

Interpolating Numeric CSS Variables

We can make variables in CSS pretty easily:

:root {
  --scale: 1;
}

And we can declare them on any element:…

Geoff Graham on Sep 1, 2022
Direct link to the article Multi-Value CSS Properties With Optional Custom Property Values
custom properties

Multi-Value CSS Properties With Optional Custom Property Values

Imagine you have an element with a multi-value CSS property, such as transform: optional custom property values:

.el {
  transform: translate(100px) scale(1.5) skew(5deg);
}

Now imagine you don’t always want all the transform values to be applied, so some …

Yair Even Or on Feb 14, 2022
Direct link to the article How to Make a Pure CSS 3D Package Toggle
3d css animation custom properties

How to Make a Pure CSS 3D Package Toggle

You know how you can get cardboard boxes that come totally flat? You fold ‘em up and tape ‘em to make them into a useful box. Then when it’s time to recycle them, you cut them back apart to flatten …

Jhey Tompkins on Jan 13, 2022
Direct link to the article Don’t Fight the Cascade, Control It!
:is :where cascade cascade layers custom properties data attributes specificity

Don’t Fight the Cascade, Control It!

If you’re disciplined and make use of the inheritance that the CSS cascade provides, you’ll end up writing less CSS. But because our styles often comes from all kinds of sources — and can be a pain to structure and …

Mads Stoumann on Jan 11, 2022
  • 1
  • 2
  • 3
  • ...
  • 11
  • Older

CSS-Tricks is powered by DigitalOcean.

Keep up to date on web dev

with our hand-crafted newsletter

DigitalOcean
  • About DO
  • Cloudways
  • Legal stuff
  • Get free credit!
CSS-Tricks
  • Contact
  • Write for CSS-Tricks!
  • Advertise with us
Social
  • RSS Feeds
  • CodePen
  • Mastodon
  • Bluesky
Back to Top