# Dynamic Colors with Relative Color Syntax

> Modify colors directly in CSS with relative syntax

Published: 2024-11-24  
Tags: css  
Source: https://www.rege-dev.xyz/writing/relative-colors

Relative Color Syntax allows you to take any existing color and modify it on the fly, such as adding transparency to a variable. [Read more on MDN →](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_colors/Relative_colors)

```css
.element {
  --brand-color: #3b82f6;

  /* Modify the color directly! */
  background-color: rgb(from var(--brand-color) r g b / 50%);
}
```

_Interactive demo: https://www.rege-dev.xyz/writing/relative-colors_
