The syntax would be :
:root.post {
/* cSS declarations */
}
You could have the same stylesheet on 2 pages then apply the posts
class to the HTML element.
:root {
--color-one: yellow;
--color-two: green;
background-color: var(--color-one);
color: var(--color-two);
}
:root.posts {
--color-one: green;
--color-two: yellow;
background-color: var(--color-one);
color: var(--color-two);
}
Page 1: green text on yellow background
Updated with child descendant
:root {
--color-one: yellow;
--color-two: green;
background-color: var(--color-one);
color: var(--color-two);
}
:root.posts {
--color-one: green;
--color-two: yellow;
background-color: var(--color-one);
color: var(--color-two);
}
.special {
color: #f0f;
font-style: italic;
}
:root.posts .special {
color: #f90;
font-style: normal;
text-transform: uppercase;
text-shadow: 2px 2px 6px rgba(0, 0, 0, 0.5);
}
<html>
<head>
</head>
<body>
<p>
ghjkghjkg
</p>
<p class="special">Special content</p>
</body>
</html>
Page 2: yellow text on green background
Updated with child descendant
:root {
--color-one: yellow;
--color-two: green;
background-color: var(--color-one);
color: var(--color-two);
}
:root.posts {
--color-one: green;
--color-two: yellow;
background-color: var(--color-one);
color: var(--color-two);
}
.special {
color: #f0f;
font-style: italic;
}
:root.posts .special {
color: #f90;
font-style: normal;
text-transform: uppercase;
text-shadow: 2px 2px 6px rgba(0, 0, 0, 0.5);
}
<html class="posts">
<head>
</head>
<body>
<p>
ghjkghjkg
</p>
<p class="special">Special content</p>
</body>
</html>