loading...

CSS Variables for beginners

twitter logo github logo ・1 min read

CSS Variables for beginners

:root {
    --primary-color: #f03d06;
  }

  .main-header {
    color: var(--primary-color);
  }
  .main-footer {
    background-color: var(--primary-color);
  }

To declare a CSS variable we will have to add a double dash before the name of that variable.

To access a CSS variable try:
var(--your-variable-name)

CSS variables declared in :root will make sure that all selectors can gain access to them

twitter logo DISCUSS
Classic DEV Post from Apr 11 '19

What's in your podcast rotation right now?

Curious what everyone is listening to for podcasts these days, whether it be te...

VICTOR OMONDI profile image
Software Developer | Graphics & UI/UX Designer | @DSC_MMU Lead | @MoringaSchool, @Ingressive & @CodeLN Campus Ambassador