DEV Community

VICTOR OMONDI
VICTOR OMONDI

Posted on

3 2

CSS Variables for beginners

CSS Variables for beginners

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

  .main-header {
    color: var(--primary-color);
  }
  .main-footer {
    background-color: var(--primary-color);
  }
Enter fullscreen mode Exit fullscreen mode

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

Top comments (0)

ACI image

ACI.dev: Fully Open-source AI Agent Tool-Use Infra (Composio Alternative)

100% open-source tool-use platform (backend, dev portal, integration library, SDK/MCP) that connects your AI agents to 600+ tools with multi-tenant auth, granular permissions, and access through direct function calling or a unified MCP server.

Check out our GitHub!

👋 Kindness is contagious

Engage with a wealth of insights in this thoughtful article, cherished by the supportive DEV Community. Coders of every background are encouraged to bring their perspectives and bolster our collective wisdom.

A sincere “thank you” often brightens someone’s day—share yours in the comments below!

On DEV, the act of sharing knowledge eases our journey and forges stronger community ties. Found value in this? A quick thank-you to the author can make a world of difference.

Okay