I have exhaustively searched for the solution without success, which is leading me to believe that it may not be achievable. With my limited understanding of CSS principles, I am inclined to think that this task could pose a challenge. However, before exploring alternative methods, I wanted to inquire if what I have in mind is feasible.
Essentially, my goal is to utilize a previously defined attribute within a new class in my CSS stylesheet. For instance, suppose I have classes dedicated to background and font colors as shown below:
.black { background-color: #000000; color: #000000; }
.white { background-color: #FFFFFF; color: #FFFFFF; }
If I were to create a new class (or any selector), would it be viable to leverage the value of an attribute from an existing class? This is how I envision my approach:
.newClass {
width: 100%;
height: 100%;
background-color: .black; /* intending to inherit the background-color attribute from the .black class */
}
The declaration background-color: .black;
serves as a placeholder for referencing the background-color attribute from the definition of the .black class. Is such functionality attainable using exclusively CSS? While I am familiar with various alternatives involving PHP/JS, I am curious to know if CSS alone can address this issue. Thank you all for your insights.