473,382 Members | 1,389 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

CSS Inheritance

Hi,

Is it possible to do this...

..MyStyle{

color: White;
font-family: Verdana;
font-size: 10px;
background-color: Blue;

}

..MyNewStyle{

INHERIT ALL THE STUFF FROM MyStyle
background-color: Red; /* OVERRIDE THE BGCOLOR*/

}
So, what I mean is, can I inherit and override certain properties from
another style. This will save me repeating the same style just to
change one property.

Thanks.
Jul 20 '05 #1
6 8817
Els
Luke wrote:
Hi,

Is it possible to do this...

.MyStyle{

color: White;
font-family: Verdana;
font-size: 10px;
background-color: Blue;

}

.MyNewStyle{

INHERIT ALL THE STUFF FROM MyStyle
background-color: Red; /* OVERRIDE THE BGCOLOR*/

}
So, what I mean is, can I inherit and override certain
properties from another style. This will save me repeating
the same style just to change one property.


Yes, by writing it like this:
..MyStyle, .MyNewStyle{

color: White;
font-family: Verdana;
font-size: 10px;
background-color: Blue;

}

..MyNewStyle{

INHERIT ALL THE STUFF FROM MyStyle
background-color: Red; /* OVERRIDE THE BGCOLOR*/

}

HTH

--
Els
http://locusmeus.com/
Sonhos vem. Sonhos vão. O resto é imperfeito.
- Renato Russo -
Jul 20 '05 #2

"Luke" <lu**********@ihsti.com> wrote in message
news:7e*************************@posting.google.co m...
Hi,

Is it possible to do this...

.MyStyle{

color: White;
font-family: Verdana;
font-size: 10px;
background-color: Blue;

}

.MyNewStyle{

INHERIT ALL THE STUFF FROM MyStyle
background-color: Red; /* OVERRIDE THE BGCOLOR*/

}
So, what I mean is, can I inherit and override certain properties from
another style. This will save me repeating the same style just to
change one property.


No, CSS doesn't provide that. What you CAN do is:

..MyStyle{
color: White;
font-family: Verdana;
font-size: 10px;
background-color: Blue;
}
..MyNewStyle{
background-color: Red;
}

and later

<div class="MyStyle MyNewStyle">...

with the class names separate by white space. Netscape 4.x won't recognize
this, and I don't know which version of IE first accepted it but IE6
understands it, as do the more advanced browsers.
Jul 20 '05 #3
> So, what I mean is, can I inherit and override certain properties from
another style. This will save me repeating the same style just to
change one property.


<div class="MyStyle MyNewStyle">...</div>

Pretty sure that'll do it, if anyone has another suggestion, feel free!

Nick.
Jul 20 '05 #4
In article <7e*************************@posting.google.com> , Luke writes:
Is it possible to do this...

.MyStyle{
color: White;
font-family: Verdana;
font-size: 10px;
background-color: Blue;
}

.MyNewStyle{
INHERIT ALL THE STUFF FROM MyStyle
background-color: Red; /* OVERRIDE THE BGCOLOR*/
}


That can be done this way:

..MyStyle, .MyNewStyle{
color: White;
font-family: Verdana;
font-size: 10px;
background-color: Blue;
}

..MyNewStyle{
background-color: Red; /* OVERRIDE THE BGCOLOR*/
}

--
Michael F. Stemper
#include <Standard_Disclaimer>
Outside of a dog, a book is man's best friend.
Inside of a dog, it's too dark to read.

Jul 20 '05 #5


Luke wrote:

Is it possible to do this...

.MyStyle{

color: White;
font-family: Verdana;
font-size: 10px;
background-color: Blue;

}

.MyNewStyle{

INHERIT ALL THE STUFF FROM MyStyle
background-color: Red; /* OVERRIDE THE BGCOLOR*/

}
So, what I mean is, can I inherit and override certain properties from
another style. This will save me repeating the same style just to
change one property.


You have two rules above and in CSS (at least in CSS 1 and CSS 2) there
is no mechanism to let one rule inherit from an earlier rule.

But of course you can use the class attribute to have an element styled
according to more than one class e.g.
<div class="MyStyle MyNewStyle">

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 20 '05 #6
On 19 Aug 2004, Luke wrote:
Is it possible to do this...

font-family: Verdana;
font-size: 10px;


Possible - but very naughty! This has been discussed to death here.
For example <http://www.html-faq.com/csspresentation/?verdana>

--
Top-posting.
What's the most irritating thing on Usenet?

Jul 20 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: AIM | last post by:
Error in msvc in building inheritance.obj to build hello.pyd Hello, I am trying to build the boost 1.31.0 sample extension hello.cpp. I can not compile the file inheritance.cpp because the two...
2
by: Graham Banks | last post by:
Does using multiple inheritance introduce any more performance overhead than single inheritance?
4
by: JKop | last post by:
I'm starting to think that whenever you derive one class from another, that you should use virtual inheritance *all* the time, unless you have an explicit reason not to. I'm even thinking that...
5
by: Morgan Cheng | last post by:
It seems no pattern defined by GoF takes advantage of multiple inheritance. I am wondering if there is a situation where multiple inheritance is a necessary solution. When coding in C++, should...
10
by: davidrubin | last post by:
Structural inheritance (inheriting implementation) is equivalent to composition in that a particular method must either call 'Base::foo' or invoke 'base.foo'. Apparantly, The Literature tells us to...
14
by: Steve Jorgensen | last post by:
Recently, I tried and did a poor job explaining an idea I've had for handling a particular case of implementation inheritance that would be easy and obvious in a fully OOP language, but is not at...
22
by: Matthew Louden | last post by:
I want to know why C# doesnt support multiple inheritance? But why we can inherit multiple interfaces instead? I know this is the rule, but I dont understand why. Can anyone give me some concrete...
45
by: Ben Blank | last post by:
I'm writing a family of classes which all inherit most of their methods and code (including constructors) from a single base class. When attempting to instance one of the derived classes using...
60
by: Shawnk | last post by:
Some Sr. colleges and I have had an on going discussion relative to when and if C# will ever support 'true' multiple inheritance. Relevant to this, I wanted to query the C# community (the...
6
by: Bart Simpson | last post by:
I remember reading on parashift recently, that "Composition is for code reuse, inheritance is for flexibility" see (http://www.parashift.com/c++-faq-lite/smalltalk.html#faq-30.4) This confused...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.