I would like to apply on some selector a style which is already defined on another selector (when applicable).
I would like to do this since I have a style that is already defined in some external CSS file on some selector. And I want to replicate this style on some other selector, without copy-paste or the need to edit my CSS file if the external CSS file changes in the future (divide and conquer).
Something like this:
External CSS file:
table tfoot td {
background: -webkit-gradient(linear, left top, left bottom, from(#ffffff), to(#cfcfcf));
}
My CSS file:
table thead td {
getStyle(table tfoot td);
}
Is this possible?
You can’t really do that in native CSS. You’d need to use a pre-processor like SCSS or LESS and use variables.
Clarification: as Triztian pointed out in his comment you can use native CSS to do this with a reusable selector like a class, but the actual copying of a style from one selector to another isn’t possible.