Skip to content

Instantly share code, notes, and snippets.

@VictorOmondi1997
Created December 2, 2019 07:12
Show Gist options
  • Save VictorOmondi1997/4adf15731c0532dd0d538b6bb464bf66 to your computer and use it in GitHub Desktop.
Save VictorOmondi1997/4adf15731c0532dd0d538b6bb464bf66 to your computer and use it in GitHub Desktop.
CSS variables for beginners

CSS Variables for beginners

:root {
    --imary-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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment