---
title: "Discussion on \"Custom Properties in CSS : A handful approach to write your code\" | Hashnode"
description: "Discussion on \"Custom Properties in CSS : A handful approach to write your code\". Nobody likes to scour through thousands of lines of CSS just to change a hex code or a margin value. One of the most commonly cited reasons for using CSS preprocessors like Sass or Less is the ability to use variables in your style sheets.\nUsing vari..."
url: "https://hashnode.com/posts/custom-properties-in-css-a-handful-approach-to-write-your-code/60fd0b7718fbbb77c946706d"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Custom Properties in CSS : A handful approach to write your code](https://saurav017.hashnode.dev/custom-properties-in-css-a-handful-approach-to-write-your-code?utm_source=hashnode&utm_medium=feed)

Nobody likes to scour through thousands of lines of CSS just to change a hex code or a margin value. One of the most commonly cited reasons for using CSS preprocessors like Sass or Less is the ability to use variables in your style sheets. Using vari...

Jul 25, 2021 · 3 min read · saurav017.hashnode.dev  
Read the article

-   [#css](https://hashnode.com/tag/css)
-   [#web-development](https://hashnode.com/tag/web-development)
-   [#webdev](https://hashnode.com/tag/webdev)
-   [#frontend](https://hashnode.com/tag/frontend)
-   [#programming](https://hashnode.com/tag/programming)

## Written by

[Saurav Purohit](https://hashnode.com/@saurav017)

@saurav017 · India

  
[View profile](https://hashnode.com/@saurav017)

A Front End Enthusiast

## Responses 4

Markdown supported · ⌘↵ to post

[Alex Rama](https://hashnode.com/@Casinorama)

[Aug 24, 2021](https://hashnode.com/posts/custom-properties-in-css-a-handful-approach-to-write-your-code/60fd0b7718fbbb77c946706d/comment/6124d755663d427e19ffa20f)

good

[Hanu](https://hashnode.com/@hanu)

[Aug 15, 2021](https://hashnode.com/posts/custom-properties-in-css-a-handful-approach-to-write-your-code/60fd0b7718fbbb77c946706d/comment/6118bf4f888ca15f5d38a24b)

Good one !!

[TnvMadhav](https://hashnode.com/@tnvmadhav)

[Jul 28, 2021](https://hashnode.com/posts/custom-properties-in-css-a-handful-approach-to-write-your-code/60fd0b7718fbbb77c946706d/comment/610123d7d3dd5634ae90760a)

Thank you for this!

[Kylon Tyner](https://hashnode.com/@ktyner)

[Jul 28, 2021](https://hashnode.com/posts/custom-properties-in-css-a-handful-approach-to-write-your-code/60fd0b7718fbbb77c946706d/comment/6100a83b2db92534dc931deb)

Excellent write-up! Something I've found annoying with the variables is that if you create a variable like this:

```
--clr-primary: #fa0e9d;
```

you can't then use that variable like so:

```
background-color: rgba(var(--clr-primary), 0.5)
```

A solution I've found is to create 2 variables:

```
:root {
  --clr-primary: rgb(var(--clr-primary-rgb));
  --clr-primary-rgb: 250, 14, 157;
}

.otherElement {
  background-color: rgba(var(--clr-primary-rgb), 0.5);
}
```

Cheers 🍻

[Saurav Purohit](https://hashnode.com/@saurav017)

[Jul 29, 2021](https://hashnode.com/posts/custom-properties-in-css-a-handful-approach-to-write-your-code/60fd0b7718fbbb77c946706d/comment/6100a83b2db92534dc931deb#reply-61023ae4d3dd5634ae9091e4)

Thanks for adding Mate😃🙏🏻
