473,323 Members | 1,589 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,323 software developers and data experts.

Suggestion: Inheritance

Hi,

when I'm programming style sheets for a whole web application I'm missing a
CSS feature to be able to reference CSS properties of other elements.
Let's say there is a background/foreground colour combination of:

BasicStyles.css:
----------------
body
{
background-color: white;
color: red;
}
I suggest to add a feature to CSS be able to reference these values in
another style sheet, e.g. to be able to invert the basic colours without
actually being required to *know* the explicit colour values. For instance:

ParticularStyles.css:
----------------
.emphasize
{
background-color: red;
color: white;
}
should become something like:

ParticularStyles.css:
----------------
.emphasize
{
background-color: body.color; -- using the computed colour of the body
element
color: inherited.background-color; using the computed inherited
background-colour
}
Axel Dahmen
Jul 21 '05 #1
9 1700
In <d5**********@online.de>, Axel Dahmen wrote:

when I'm programming style sheets for a whole web application I'm missing a
CSS feature to be able to reference CSS properties of other elements.

I suggest to add a feature to CSS be able to reference these values in
another style sheet, e.g. to be able to invert the basic colours without
actually being required to *know* the explicit colour values. For instance:


What wrong with @import "BasicStyles.css"; in ParticularStyles.css ?

--
|":._.:"| http://habett.com/
| (=) | http://habett.org/
|\. | ./| http://www.roux.to/
Jul 21 '05 #2
Axel Dahmen wrote:
when I'm programming style sheets for a whole web application I'm missing a
CSS feature to be able to reference CSS properties of other elements.


Yeah, I've often wished for something similar. This topic has been
raised before, but in the absence of any changes to CSS and concommitant
changes to the browsers, the suggestion has simply been made to use
server-side code or a preprocessor to generate the desired CSS, with the
smarts built into the code or preprocessor.
Jul 21 '05 #3
Then let's start a fraction to suggest this kind of functionality. CSS3 is
under development, so it's the right time to suggest amendments.

I believe this to be a necessary feature. Particularly if you want to
provide a homogeneous design throughout several style sheets.

One typical application would be giving customers the option to change basic
styles (like body background-color) and to automatically have detail
elements match accordingly (like in the given example).

RFC
Axel Dahmen

--------------
"C A Upsdell" <""cupsdellXXX\"@-@-@XXXupsdell.com"> schrieb im Newsbeitrag
news:_d********************@rogers.com...
Axel Dahmen wrote:
when I'm programming style sheets for a whole web application I'm missing a CSS feature to be able to reference CSS properties of other elements.


Yeah, I've often wished for something similar. This topic has been
raised before, but in the absence of any changes to CSS and concommitant
changes to the browsers, the suggestion has simply been made to use
server-side code or a preprocessor to generate the desired CSS, with the
smarts built into the code or preprocessor.

Jul 21 '05 #4
The requested feature doesn't necessarily require a parent style sheet or
prior CSS declarations of any kind as it refers to computed values.

I've just omitted to @import rule in the example.

Axel Dahmen

------
"Stephane Roux (HAbeTT)" <ha****@habett.org> schrieb im Newsbeitrag
news:d3***************@habett.habett.org...
In <d5**********@online.de>, Axel Dahmen wrote:

when I'm programming style sheets for a whole web application I'm missing a CSS feature to be able to reference CSS properties of other elements.

I suggest to add a feature to CSS be able to reference these values in
another style sheet, e.g. to be able to invert the basic colours without
actually being required to *know* the explicit colour values. For
instance:
What wrong with @import "BasicStyles.css"; in ParticularStyles.css ?

--
|":._.:"| http://habett.com/
| (=) | http://habett.org/
|\. | ./| http://www.roux.to/

Jul 21 '05 #5
Axel Dahmen schrieb:
[Variables]
Then let's start a fraction to suggest this kind of functionality.


Every other week there is such a proposal on www-style, of which very
few are thought through at all. They all get turned down, they don't
even get a reply from any WG member now. The most important reason is
simple: It's not implementable backwards compatibly. Another unresolved
issue is the cascade, it's too easy to have a variable overwritten badly
later on.

So if you are, as you wrote, *programming* your stylesheets, you can
easily do what you want with that programming language.

Furthermore, many instances can be solved by clever use of existing CSS
features, like grouped selectors or inheritance and maybe collapsing or
transparency.
Jul 21 '05 #6
> The most important reason is
simple: It's not implementable backwards compatibly.
It doesn't matter if you add a new property or new values to a property. An
old application will never understand the new features. But it is important
to have the old application ignore the new feature and not behave
erroneously.

To make it backward compatible, any reasonable escape character may be used
to precede a computed back-reference as proposed, like:

h1
{
background-color: >body.color;
}

Old applications will interpret this like they would interpret any new
property, like e.g. "display: inline-block", i.e. they will not interpret
this at all.

Another unresolved
issue is the cascade, it's too easy to have a variable overwritten badly
later on.
My suggestion is not about variables but on using currently computed values
instead of constants. This should render this issue solved. -- No
programming. More or less it's as simple as just using run-time instead of
design-time.
So if you are, as you wrote, *programming* your stylesheets, you can
easily do what you want with that programming language.
The feature request is not about programming, I'm just using current values
instead of constants. This would render creating style sheets far more easy.
E.g. you would not have to amend each and every element you assigned some
corporate colour to, when this corporate colour is changed by the design
department.

Currently styles are quite rigid and dependant because explicit values have
to be used with each and every element, making editing rather awkward and
complicated. Using computed back-reference values, a corporate colour would
only have to be assigned to some selector once and can then be used
throughout the whole website. It doesn't even need to be assigned at all, as
back-reference, like the one proposed, uses the currently computed value,
hence using whatever value is computed for the referenced selector.

Furthermore, many instances can be solved by clever use of existing CSS
features, like grouped selectors or inheritance and maybe collapsing or
transparency.


This would be like riding a horse from behind. Moreover, these suggestions
are clumsy and inflexible as well:

* Inheritance can not be used if you want to have *several*
properties share e.g. the same colour.

* If a designer would use grouped selectors, he might be
forced to create loads of groups having some same properties
and then he would need to assign a bunch of these groups to
any element. This would be more like designing a nuclear
power station than designing a website.

* Collapsing and transparency? So you actually want to put
design into code?

No, this can all much more easily be solved using a feature like the one I'm
suggesting.
Axel Dahmen
Jul 21 '05 #7
[attribution restored]

Christoph Päper <ch**************@nurfuerspam.de> wrote:
Another unresolved issue is the cascade, it's too easy to have a
variable overwritten badly later on.
Axel Dahmen <NO*****@NoOneKnows.invalid> wrote:
My suggestion is not about variables but on using currently computed values
instead of constants. This should render this issue solved. -- No
programming. More or less it's as simple as just using run-time instead of
design-time.


You seem to have missed the issue of the cascade.

What happens when you cascade the author style sheet

body { color : black ; background : white ; }
h1 { color : silver ; background : >body.color ; }

with the user style sheet

body { color : white !important ; background : black !important ; }

? The H1 element is displayed silver-on-white, which isn't very legible.

That's why style sheets should specify an explicit color (not "inherit" and
not "transparent" and not a runtime value like you're suggesting) and an
explicit background (not "inherit", etc.) together.
So if you are, as you wrote, *programming* your stylesheets, you can
easily do what you want with that programming language.


The feature request is not about programming, I'm just using current values
instead of constants. This would render creating style sheets far more easy.
E.g. you would not have to amend each and every element you assigned some
corporate colour to, when this corporate colour is changed by the design
department.


I use the same preprocessor to generate my CSS as I use to generate my
HTML. I define the color scheme once, and then the preprocessor inserts the
specified colors where necessary. If I change the color scheme, then I
change it once, and the preprocessor handles the rest.

That's the advantage of using a programming language, rather than trying to
convert CSS into a programming language.
--
Darin McGrew, mc****@stanfordalumni.org, http://www.rahul.net/mcgrew/
Web Design Group, da***@htmlhelp.com, http://www.HTMLHelp.com/

"Timing has a lot to do with the outcome of a rain dance."
Jul 21 '05 #8
> You seem to have missed the issue of the cascade.

What happens when you cascade the author style sheet

body { color : black ; background : white ; }
h1 { color : silver ; background : >body.color ; }

with the user style sheet

body { color : white !important ; background : black !important ; }

? The H1 element is displayed silver-on-white, which isn't very legible.

I don't see a contradiction in that. Using the current implementation
cascading can also have unfortunate constellations like:

body { color: black ; background: white ; }
h1 { color: darkred ; background: transparent; }

with the user style sheet

body { color: white !important ; background: black !important ; }
That's why style sheets should specify an explicit color (not "inherit" and not "transparent" and not a runtime value like you're suggesting) and an
explicit background (not "inherit", etc.) together.
Still values like "inherit" and "transparent" belong to the current
standard. What would you suggest to use e.g. on bitmapped backgrounds?

I use the same preprocessor to generate my CSS as I use to generate my
HTML. I define the color scheme once, and then the preprocessor inserts the specified colors where necessary. If I change the color scheme, then I
change it once, and the preprocessor handles the rest.


I'm not using any pre-processor at all, neither for CSS nor HTML. That's the
advantage of a comprehensive standard. Again, using runtime-values instead
of design-time values is not programming. It gives the liberty to update
certain definitions (or CSS files, resp.) and have the other definitions
match these.

If a designer wants to provide custom skins for his website (e.g. e-shop
templates), it is a great advantage if the customers only need to provide a
simple updated basic style sheet, having all detail elements follow the new
colour scheme.
Jul 21 '05 #9

Now continued at:

http://lists.w3.org/Archives/Public/...5May/0059.html


------------
"Axel Dahmen" <NO*****@NoOneKnows.invalid> schrieb im Newsbeitrag
news:d5**********@online.de...
Hi,

when I'm programming style sheets for a whole web application I'm missing a CSS feature to be able to reference CSS properties of other elements.
Let's say there is a background/foreground colour combination of:

BasicStyles.css:
----------------
body
{
background-color: white;
color: red;
}
I suggest to add a feature to CSS be able to reference these values in
another style sheet, e.g. to be able to invert the basic colours without
actually being required to *know* the explicit colour values. For instance:
ParticularStyles.css:
----------------
.emphasize
{
background-color: red;
color: white;
}
should become something like:

ParticularStyles.css:
----------------
.emphasize
{
background-color: body.color; -- using the computed colour of the body element
color: inherited.background-color; using the computed inherited
background-colour
}
Axel Dahmen

Jul 21 '05 #10

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

Similar topics

11
by: Ricky Romaya | last post by:
Hi, Are there any ways to get multiple inheritace in PHP4? For example, I have 3 parent class, class A, B, and C. I want class X to inherit all those 3 classes. Consider merging those 3 classes...
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...
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...
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...
20
by: W Karas | last post by:
Would the fear factor for concepts be slightly reduced if, instead of: concept C<typename T> { typename T::S; int T::mem(); int nonmem(); };
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...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
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...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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...

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.