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
  • 37,952
  • 20
  • 92
  • 95
Ekata
  • 259
  • 2
  • 7
  • 21

3 Answers3

2

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

somdow
  • 6,268
  • 10
  • 40
  • 58
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,350
  • 2
  • 25
  • 44
0

You can make it with SASS:

$bodyColor: #000;

body {
    color: $bodyColor;
}
arturas
  • 1,027
  • 1
  • 9
  • 26