DEV Community

Calvin
Calvin

Posted on

2

Reading Snippets [32 => CSS]

Custom properties contain specific values to be reused in a document.

Custom property notation (e.g., --main-color:black;) is used to set custom properties.

Declaration of custom property on the :root pseudo-class allows for use where needed throughout a document.

The var() function is used to access custom properties.

Example:

Declaring a custom property:


element {
  --main-bg-color:brown;
}

Enter fullscreen mode Exit fullscreen mode

Using the custom property:


element {
  background-color:var(--main-bg-color);
}

Enter fullscreen mode Exit fullscreen mode

Source:Developer.Mozilla

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay