The limitation of inline styles
A blog can give each post a per-author color, chosen in the CMS and emitted on the front end as an inline style attribute on the <article> element. Templating with Liquid or any comparable language makes that trivial:
{% for post in posts %}
<article style="background: {{post.custom_color}}">
<h1>{{post.title}}</h1>
{{content}}
</article>
{% endfor %}
What inline styles cannot express is state. You cannot write a hover rule inside a style attribute. Attempting the obvious CSS version:
article {
background: lightgray !important;
}
article:hover {
/* Doesn't work! */
background: inherit;
}
fails because the inline declaration wins over the stylesheet rule. !important can override an inline style, but there is no way to undo that override on hover.
Store the value instead of applying it
The fix is to use the inline attribute purely as a carrier for the CMS value, writing it into a custom property rather than the color property directly:
<article style="--custom_color: {{post.custom_color}}">
<h1>{{post.title}}</h1>
{{content}}
</article>
The hover rule then lives in a normal stylesheet and reads that variable:
article {
background: lightgray;
}
article:hover {
/* Works! */
background: var(--custom_color);
}
Because declarations are evaluated at match time, the custom color appears only when the pointer is over the card.
Reusing the scoped value
Once the color is a variable, other rules on the same element can consume it. All links inside the post can pick up the custom color:
article a {
color: var(--custom_color);
}
Since the property is scoped to the <article> element, it cannot leak to the rest of the page, and multiple posts can be rendered on one page each with its own color.
Compatibility
Support for CSS variables is broadly available with the exception of Internet Explorer, which makes the technique safe for CMS-driven light art direction.



