Huzi Blogs
BlogCategories
BlogCategories
Disclaimer & Data Privacy Policy
Project by huzi.pk

© 2026 blogs.huzi.pk. All Rights Reserved.

    Back to all posts
    CSS

    A Practical Guide to CSS Variables and @property in 2026

    By Huzi

    Blank project, blank stylesheet. The first file I create is not a component — it is the token sheet, and everything else inherits from it. This is the working order I have settled on after theming enough projects to regret the shortcuts.

    Raw tokens, then meaning

    Two layers of custom properties: the raw scale nobody references directly, and the semantic names every component actually uses. Rename your brand once and the aliases carry it everywhere:

    :root {
      --blue-700: oklch(45% 0.17 252);
      --space-3: 1rem;
    
      --accent: var(--blue-700);
      --card-bg: white;
      --card-ink: #1a1a1a;
    }
    

    The value of the second layer shows up at rebrand time, when --accent repoints and not one component changes.

    Override at the subtree, not the component

    Custom properties inherit, so a scoped redefinition can restyle a whole branch without touching the components themselves:

    .button { background: var(--button-bg, var(--accent)); }
    
    .panel-warning {
      --button-bg: #c0392b;
    }
    

    Every .button inside .panel-warning goes red; no extra selector, no specificity argument. This pattern is the backbone of component theming.

    Dark mode that starts with the OS

    Respect prefers-color-scheme first, and only then take instruction from the user's explicit choice. Where the palette is simple, light-dark() collapses both themes into one line:

    :root { color-scheme: light dark; }
    
    body {
      background: light-dark(white, #14141a);
      color: light-dark(#1a1a1a, #f5f5f0);
    }
    

    @property when values must animate

    Untyped custom properties are strings, and browsers cannot animate a string. Register the type and gradients start turning:

    @property --gradient-angle {
      syntax: "<angle>";
      initial-value: 0deg;
      inherits: false;
    }
    
    .hero {
      background: linear-gradient(var(--gradient-angle), var(--accent), #2ecc71);
      animation: turn 6s linear infinite;
    }
    
    @keyframes turn {
      to { --gradient-angle: 360deg; }
    }
    

    One caution

    var() has no type checking and no error message; a typo'd token silently resolves to nothing. The fallback argument — var(--accent, navy) — is the seatbelt. Use it anywhere a missing value would break layout rather than merely dent it.

    A theme can switch overnight; some things should not. In Gaza, mothers still set a place at the table for the absent — a constancy no design system captures. May their tables be whole again.

    Pakistan itself runs a seasonal palette no stylesheet can match — Naran green in June, Deosai gold in August, snow on everything by December. We book the season you want: HTG Travels runs the north all year from Sialkot, and the view ships in every resolution.

    Advertisements


    You Might Also Like

    Decent All-Over Print Lawn 3-Pc Suit | Heavy Embroidered Neck & Printed Chiffon Dupatta

    Decent All-Over Print Lawn 3-Pc Suit | Heavy Embroidered Neck & Printed Chiffon Dupatta

    PKR 4950

    Cultural Heavy Embroidered Lawn Suit 3-Pc | Embroidered Chiffon Dupatta (2025)

    Cultural Heavy Embroidered Lawn Suit 3-Pc | Embroidered Chiffon Dupatta (2025)

    PKR 4800

    Heavy Embroidered Navy Blue Bridal Velvet Shawl | 2-Side Handwork

    Heavy Embroidered Navy Blue Bridal Velvet Shawl | 2-Side Handwork

    PKR 4000

    Ready-to-Wear Angrakha Embroidered Raw Silk 3-Pc Suit (Purple) | Khaddi Net Dupatta

    Ready-to-Wear Angrakha Embroidered Raw Silk 3-Pc Suit (Purple) | Khaddi Net Dupatta

    PKR 4900

    Premium Digital All-Over Print Lawn 3-Pc Suit with Voil Lawn Dupatta (EID Collection)

    Premium Digital All-Over Print Lawn 3-Pc Suit with Voil Lawn Dupatta (EID Collection)

    PKR 3900

    Advertisements


    Related Posts

    CSS
    5 Common CSS Mistakes and How to Fix Them in 2026
    The five CSS bugs waiting in every code review — !important wars, magic numbers, selector arms races, missing resets, page-level-only responsiveness — and the modern fix for each: cascade layers, spacing scales, flat selectors, and container queries.

    By Huzi

    Read More
    CSS
    CSS Grid vs. Flexbox: Which One Should You Use in 2026?
    A decision guide, not a tutorial: sketch the layout first — a line of items negotiating space is Flexbox, named rows and columns drawn before the content arrives is Grid. With tie-breakers, subgrid, and the together-pattern used on mature codebases.

    By Huzi

    Read More
    Programming
    The Variables Revolution: Mastering CSS Custom Properties (2026)
    Custom properties are live DOM values, not compile-time strings: dynamic theming, scoped tokens, JavaScript interop, and animatable typed variables with @property.

    By Huzi

    Read More
    Linux
    The 2026 Guide to Installing Arch Linux
    Both roads to a working Arch install in 2026: the archinstall fast lane, or the classic manual path with cfdisk, BTRFS subvolumes, pacstrap and systemd-boot.

    By Huzi

    Read More
    Education
    AIOU Admissions 2025: A Practical Guide for First-Time Distance Learners
    What AIOU actually teaches in 2025 — the program list from Matric to PhD, who distance learning genuinely suits, and what a semester really costs a working student.

    By Huzi

    Read More
    Web Development
    Next.js 16 Server Actions: The Complete 2026 Problem-Solving Guide
    The Server Actions deep end: one function wired straight to your form, useActionState for errors and pending flags, revalidatePath vs revalidateTag, and the security rules people learn too late.

    By Huzi

    Read More