
A page can move through several visual moods without needing a separate set of component styles for every section. Set an accent color on the section and let its children inherit that value. This is a useful way to organize a long, expressive page while keeping the CSS manageable.
Change the CSS below. The preview updates as you type. Your edits stay in this browser tab.
Edit each section’s --accent. Headings, borders, and links inherit the local color.
HTML for this example
<div class="section-stack"><section class="brand-section brand-section--one"><span>01 / Discover</span><h2>Find the direction.</h2><p>One reusable component, with a color chosen for this section.</p><a href="#section-note">Explore this step →</a></section><section class="brand-section brand-section--two"><span>02 / Create</span><h2>Bring it together.</h2><p>The same rules inherit a different accent here.</p><a href="#section-note">Explore this step →</a></section></div><p id="section-note" class="example-note">Fictional sections for experimenting with local theme colors.</p>
Scope the variable to the section
Each modifier class sets --accent and --surface. The shared heading, border, and link rules read those variables with var(). Change one value and all the connected details update together. A section’s variable also reaches nested components unless a more specific scope overrides it.
Use fallback values deliberately
The second argument in var(--accent, #00555d) is used when that custom property is missing or invalid as a variable. It does not check whether your chosen color contrasts with its background, and it does not rescue every invalid value at the property level. Define a small set of tested color pairs rather than letting arbitrary colors become text colors.
Keep structure understandable without color
Each section still has a heading and visible step label. Color reinforces the structure instead of carrying it alone. The inspiration here is Chris Temple Yoga, where sections use chakra-related colors alongside their own content and navigation. This simplified example uses fictional steps and a separate palette.
See the design context on Chris Temple Yoga; this demo is an independent explanation of section-level styling.
Reference: MDN on using CSS custom properties.
Have a client website that needs this kind of attention? See our WordPress development for agencies and case studies.


Leave a Reply