This is currently not possible without any preprocessors such as Less. There is however a quite new proposal to implement CSS variables some time in the far future. For now though, this is not possible using plain CSS. There are 2 things you can do now:
1. Use a preprocessor
You could use a preprocessor, such as LESS or SCSS. In the case of LESS, you would need to use mixins, and in SCSS you would need to extend the existing class. There are more CSS preprocessors, but these are the most popular ones.
The syntax you're using would be the exact same syntax as the syntax required in Less.
SCSS demo, LESS demo
2. Use JavaScript
If you're running your site on a server you can't easily access yourself, or if you have any other reason not to be able to install such preprocessors, you could use JavaScript as an alternative. You would have to run a script that scans all of the class's applied styles. This would work (based on this SO answer), but do watch out with cross-domain rules.
function applyRules(from, to) {
var sheets = document.styleSheets;
var re = new RegExp('(^|,)\\s*'+from+'\\s*(,|$)');
var rules, curr;
var styles = '';
for (var i=0;i<sheets.length;i++) {
rules = sheets[i].rules || sheets[i].cssRules;
for (var j=0;j<rules.length;j++) {
if (re.test(rules[j].selectorText)) {
curr = rules[j].cssText || rules[j].style.cssText;
styles += ';' + curr.substring(curr.indexOf('{')+1, curr.indexOf('}'));
}
}
}
var sheet = document.createElement('style');
sheet.type = 'text/css';
sheet.innerHTML = to + '{' + styles + '}';
document.head.appendChild(sheet);
return sheet;
}
applyRules('.red', 'button:hover');
Demo.
That will search through all accessible stylesheets for a style that selects for .red
, and apply those styles to button:hover
.