How can I inherit properties from the css id rule to the css class?

Just include the ID class on the upper declartion, the last declaration for any property wins. E.g. If the first rule had a color: Green test would be green divNew would still be red.

Just include the ID class on the upper declartion, the last declaration for any property wins. E.g. If the first rule had a color: Green;, .

Test would be green, #divNew would still be red. . Test, #divNew{ text-align:center; font-family:Verdana; } #divNew{ color: Red; }.

Beat me to it :( – Chris Jan 27 '10 at 14:33 You know object oriented inheritence like that: "class NewClass : OldClass" or in java "class NewClass extends OldClass" . Is therey any way to do it like that? – uzay95 Jan 27 '10 at 14:34 You can't, you can make use of nested classes, for example this will merge both style declarations to the div.

– F. Aquino Jan 27 '10 at 14:36 This the correct answer. Simply put, when you declare a new style, you can separate the list of items (classes or ID's) with a comma.

If you want to override those attributes for just one of those items (in this case "#divNew"), you just need to re-declare another set of attributes for that item AFTER the initial declaration, exactly as per Nick's example. This supported even in legacy versions of MISE. – Iain Collins Jan 27 '10 at 14:39 @uzay95 CSS just doesn't work that way, this is as close as it gets :) – Nick Craver?

Jan 27 '10 at 14:44.

I believe the question is, can my "#divNew" CSS rule inherit the properties of the existing ". Test" rule so that: Psuedo Code . Test { color: red; } #divNew : .

Test { border: 1px solid Black } ... results in an element with an id of #divNew getting both red text and a black border. And the answer is no - there is no syntax for declaring the inheritance of one rule by another rule - but you can apply multiple CSS rules to one element. In this example, the element would take the rules for "#divNew" and ".

Test" and ". Another". It would override any conflicting properties with the last rule in your CSS....

LESS/dotLess allow you to perform additional processing within a CSS file on the server side, using a CSS style syntax. LESS. I'd link to dotLess, but I can't find a functioning link at present (dotlesscss.com/ is coming up empty for me) edit Or T4CSS from Phil Haack.

– uzay95 Jan 27 '10 at 14:29 Sorry... right you are. Nick is right.In CSS the last style to be declared will be inherited. – jeerose Jan 27 '10 at 14:36.

Not sure to understand you, but: . Test{ text-align:center; font-family:Verdana; } #divNew. Test{ color: Red; }.

If in your HTML #divNew is a child of . Test, then CSS properties of . Test are already inherited by it (unless you override them by setting specific #divNew properties).

Syntax for adding properties directly to #divNew which is also . Test: #divNew. Test {/*properties*/} Syntax for adding properties to #divNew which is a child of .

Test: . Test #divNew {/*properties*/}.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions