Inheritance in CSS

Hi all ,
Please forgive me about this question since i'm asking just because I don't have the time to look for the answer and I hope someone will know the answer without spending time on it.

So , for the question  , Is there a way to inhert CSS properties from one class to another ?

For example :

FURNITURE  
  {
  made-off:wood;
  }

DOOR
  {
  typeof: "FUNRNITURE";
  shape:like-square-but-not;
  }

and when using this CSS block , DOOR will be "made-off" wood.

Does someone knows of anything similer ??

Please don't get into the "inherit" peropertie since I am familier with it , and it has nothing to do with my questions.

Thanks in advance,

                  Avner.
LVL 14
avnerAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
klykkenConnect With a Mentor Commented:
avner,
You don't have to be afraid to use this structure of css.
This is called grouping and is quite common.
You would maybe declare a font this way for your site:
body, table, td, div, span, p {font-family:  Arial, Helvetica, sans-serif;}

This is part of the CSS standard as seen here:
http://www.w3.org/TR/REC-CSS2/selector.html#grouping

In the web-development company I work for we use this way of declaring CSS every day, so I think you can relax. Works at least on 4 browsers and up.
Thats the browsers we test our sites on anyway.

--
klykken
0
 
COBOLdinosaurCommented:
The short answer is no, but everyone knows I hate short answers.

So while it is not possible to use typing for inheritance, you can
use scoping, which probably already understand:

  .furniture {made-of:wood}
  #door {shape:like-square-but-not}
  .funiture #door {trim-type:brass}

anything with an id of "door" has the shape attribute, but if
contained in an element of class furniture it is also made of wood and
has brass trim.

I'm not sure that is what you are looking for, but that is about as
close as you can get to direct casting of the attributes based on the
value of another class.

HTH

Cd&
0
 
avnerAuthor Commented:
CD,
your suggested answer is what I already know.
I'm hoping to read something that I didn't know , I will leave this question open a little more and if I won't receive any new insights , I'll accept your answer.
thanks for the help.

avner.




0
Get 10% Off Your First Squarespace Website

Ready to showcase your work, publish content or promote your business online? With Squarespace’s award-winning templates and 24/7 customer service, getting started is simple. Head to Squarespace.com and use offer code ‘EXPERTS’ to get 10% off your first purchase.

 
klykkenCommented:
hmm what about:

.furniture, .door  {made-off: wood;}
.door { shape:like-square-but-not; }

It's not inheritance, just another way of structuring your css rules.
--
klykken
0
 
avnerAuthor Commented:
klykken ,
This is what I call a new insight !

But...
The reason why I've never tried this way of declaring CSS was because it looks weird to declatre one rule twice.

Are you 100% that on all platforms and all browsers , CSS will allow this usage ?
Have you ever notice anything about it in the W3C CSS recommandation ?


avner.

0
 
COBOLdinosaurCommented:
It's a little strange, but it works in IE.  Don't have Netscrap here to try it but there is no reason for it to not work on any browser that supports CSS.  It is just a different way of building the cascade.  Good approach klykken.  I would never have tried it that way.  Maybe I'm too conventional.

Cd&

0
 
avnerAuthor Commented:
klykken ,
Thank you very much for our help , although this is not inheritance , this way is good enough to solve my problem since the whole inheritance thing came originally from the fact that I wanted to be able to declare a "all-around-font"

and I can achive this using the grouping thing.

0
 
avnerAuthor Commented:
btw - Cd , thanks for your help, sorry I couldn't help incearsing your points status in this area , I know you need it....:)
0
 
klykkenCommented:
avner, glad to be of quick help, and thanx for the A :)
..and don't wory about COBOL, he has enogh points already ;-)

cobol: I tried some solutions with wildcards (*) until it finally struck me to use grouping this way, funny how CSS let you conceptually find different solutions to things. I would never have thought of the set of rules in your first comment.
--
klykken
0
 
COBOLdinosaurCommented:
I think I have gotten to a leve where points are not real important.  Good Qs with interesting ideas is where the fun is.  Thanks for posting this avner it makes a good addition to the PAQ.  This TA is only 1 year old but it has really great solutions in it.

Scoping is something I use all the time, and groupings as well.  I just never thought about declare the same class twice for different attribute sets.  Something else to add to the arsenal. :^)

Cd&
0
 
avnerAuthor Commented:
I'm happy to see that I am not the only one that learned.

Thanks for your help.
0
 
COBOLdinosaurCommented:
Hmmm... klykken move up into the top ten with this Q passing several other experts including avner.

Cd&
0
 
avnerAuthor Commented:
... and is well deserved it....:)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.