Is there a way to get an idea/class to have all the properties of a class/id?

Hi,

I’d like to know if the following can be done:


.some-class {
 (get all the properties of .other-class)
}

Regards,

jj. :slight_smile:

What I want to do can’t be done, then :frowning:

The mood in the CSS forum is always a pleasure :slight_smile:

As I’m sure you already knew, even as I worded my post, I was talking about this

<div style=“margin-left:100px;”><span>ljf</span></div>

Had the span inherited the left margin then the span would be 200px over. I wasn’t saying you can’t inherit stuff via being more selective with your CSS rules, not at all.


.some-class {
 (get all the properties of .other-class)
}

it appears to me you are describing cascading :slight_smile:

Not directly, but you can do this:

.someclass, .otherclass {
  // properties both classes need to have
}

.someclass {
  // properties for someclass only
}

.otherclass {
  // properties for otherclass only
}

:slight_smile:

if .other-class are children of .some-class then “inherit” in the css styles should work.

he said it wrong, but aren’t you forgetting the case when the classes are for the same element?

h1 {many css rules here}
h1.more {/*has the rules from h1 + */ additional css rules }
h1.moreandmore {/*has the rules from h1, but none from h1.more + */ some other additional css rule}

i believe it’s called exactly inheritance :wink:

h1.more {
(get all the properties of h1)
}

As others stated you can’t have a class inherit CSS :). Only a few properties inherit to children elements but most don’t (which makes sense, if margins/paddings/backgrounds inherited to children, then that’d be a mess :))

Also note that the inherit value (as the above poster has stated) will work, HOWEVER IE7 and down don’t support inherit except on a few minor properties (they won’t help you with simple designing of a page)