DEV Community

Cover image for CSS variable chapter two "how to override CSS variable" ๐Ÿคนโ€โ™‚๏ธ
๐Ÿšฉ Atul Prajapati ๐Ÿ‡ฎ๐Ÿ‡ณ
๐Ÿšฉ Atul Prajapati ๐Ÿ‡ฎ๐Ÿ‡ณ

Posted on โ€ข Edited on

6 2

CSS variable chapter two "how to override CSS variable" ๐Ÿคนโ€โ™‚๏ธ

Hello dear folks ๐Ÿ˜‰

In the last CSS variable chapter we have learned about how to create CSS variables and use them.

In this post, we'll learn about "how to overriding variables"

In some cases, we need to make changes in CSS variable values at a certain level of our project, that's why we use this override feature.

Now imagine that we want to change our item card's headline and button color, so we'll use this code in our item selector.

.item {
    --red-color: green;
    background: var(--project-card-bg);
}
Enter fullscreen mode Exit fullscreen mode

To clear your confusion look at this codepen project ๐Ÿ‘‡

hmmm, that's it for this DEV post and in the next post, we will learn about the "Local CSS variable".

If you have any questions about CSS override you can comment below, i will reply asap ;)

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where youโ€™ll build it, break it, debug it, and fix it. Youโ€™ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good olโ€™ AI to find and fix issues fast.

RSVP here โ†’

Top comments (0)

Sentry image

See why 4M developers consider Sentry, โ€œnot bad.โ€

Fixing code doesnโ€™t have to be the worst part of your day. Learn how Sentry can help.

Learn more

๐Ÿ‘‹ Kindness is contagious

Please leave a โค๏ธ or a friendly comment on this post if you found it helpful!

Okay