Is it possible in CSS to set the value of one property of a class as the same property value of another class ?
e.g.:
.classA{
color: blue;
}
.classB{
color:[likeClassA];
}
Is it possible in CSS to set the value of one property of a class as the same property value of another class ?
e.g.:
.classA{
color: blue;
}
.classB{
color:[likeClassA];
}
it is not possible but you could do this as an alternative
.classA ,.class B{
color:blue;
}
With pure CSS (i.e. not a precompiled solution) you can use CSS custom properties:
:root {
--mycolor: blue;
}
.classA {
color: var(--mycolor);
}
.classB {
color: var(--mycolor);
}
Read more: https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_custom_properties
Please note that var()
is not supported in IE11 or below. There are some solutions though including polyfills: CSS custom properties polyfill for ie11