0

Is it possible to have one css class having a property which calls another CSS class?

Example:

.redcolor {
    color:red;
}
p {
    text-align: center;
    color: redcolor;
}
Mohammad Usman
  • 34,173
  • 19
  • 88
  • 85
Ekata
  • 239
  • 2
  • 6
  • 18

3 Answers3

2

No unless you are using SASS/LESS. You are stuck with giving everything "Red" as a normal class.

somdow
  • 6,014
  • 10
  • 39
  • 55
0

No ! It is not possible in plain CSS but you can always use Some CSS Preprocessors like SASS or LESS

New Edit: Okay I was searching about it and seems your problem can be solved without using pre Preocessor have a look here

but, let me clear this is experimental as per MDN can may not be compatible in all browsers

Saurabh Bayani
  • 3,180
  • 2
  • 22
  • 42
0

You can make it with SASS:

$bodyColor: #000;

body {
    color: $bodyColor;
}
arturas
  • 854
  • 1
  • 7
  • 22