0

Lets say I have in my CSS a color definitions:

.headerColor   { background-color: #a6c9e2; }

Now I would also like to define a CSS definition that uses .headerColor:

.header        { padding-left: 2px; }

On the CSS level, how can I inherit .header from .headerColor? I know I can place the two styles on the HTML element (class='header headerColor'), but how can I assign .header to my HTML element and have it pull its parent styles?

BlueChameleon
  • 924
  • 1
  • 10
  • 36
  • Possible duplicate: [inherit from another class](http://stackoverflow.com/questions/6175633/inherit-from-another-class) – Antony Feb 15 '13 at 16:22

1 Answers1

2

You can write like this:

.headerColor, .header   { background-color: #a6c9e2; }
.header                 { padding-left: 2px; }

Now, you just need to set class="header" in HTML.

Ovilia
  • 7,066
  • 12
  • 47
  • 70
  • Thank you for this answer. I have a quick question. Lets sayI define a color: .blueColor { color: #3b5ae0; }. Now i would like to reference this color when creating css's for background-color or border-color? For example. .editor { background-color: ??(.blueColor) } – BlueChameleon Feb 15 '13 at 17:40
  • Then you will need `lesscss.org`. But usually I just copy and paste the color. – Ovilia Feb 16 '13 at 00:26