Re: Class Selectors Extension Proposals

I'm aware of letting CSS remains as a _descriptive_only_language_

Shame on me about having selected a syntactic "procedure/function call"
notation

I will try to express idea #2 (parametrized classes: reusing & extending
classes) more clearly, suppose the following scenario:

 Let be the following style sheet definition, eg "my_app_style.css"

    .x1 { a:i1; b:j1; c:k1; }
    .x2 { a:i2; b:j1; c:k1; }
    #x3 { a:i3; b:j2; c:k2; }

 Let be an HTML page:

    @import url(my_app_style.css);
    ..
    <span class="x1">    OK  :-) </span>
    <span class="x2">    OK  :-) </span>
    <span    id="x3">    OK  :-) </span>
    <!--
        Here, user realizes he/she needs a derivative x-class behavior
        but he/she do not reuse any of them because he/she needs "a:i4"
    -->
    <span style="a:i4; b:j1; c:k1;"> Bad choice!! Human makes mistakes  :-O
</span>

Is there a better CSS solution for this _user_requirement_? Let's see
(please help me if I missing something):

 (1) With standard CSS:
    <span class="x1" style="a:i4;"> Reuse x1 but change a to i4. STYLE has
higher SPECIFICITY than CLASS selector </span>

 (2) With ECMA Script, ie JavaScript:
    <span id="x3"> Reuse x3 and change an attribute value using JavaScript
</span>
    <script language="JavaScript"> x3.style.a="i4"; </script>

 (3) XML/XSLT/FOSI/DSSL: I feel it can be done but I ignore how to do it
(please help/forgive me)
    -- Other solution(s) --

 (4) With my proposal..  a little more "OO-like" as Manos said ;-)

    .x { a:i1; b:j1; c:k1; } /* Just define one x-class and reuse/extend it
*/
    ..
    <span class="x[a:i4]"> Reuse x definition but change a to i4 </span>
    <span id="x[a:i5]"> Same for ID selectors: reuse x definition but change
a to i5 </span>

I agree that (1) is (an incidental) solution but it doesn't have the (4)
expressive notational power for things like "apply class a, b and c, and for
all of them (CSS2 universal selector *) change (for example) "media"
attribute to "print":

    <div class="a b c *[media:print]"> A Slide Presentation </div>

I think this is a matter of "style": Why we have to manage style's
attributes with other non-style-based languages (such as JavaScript) when
CSS can (be extended to) do it better?

Sincerely

Alberto Pacheco
A CSS user, web-author and CSS-based-systems implementor
alberto@computer.org


PS

1. Thanks to all of you for solution for question #1 and for your precious
time and debate about question/proposal #2, specially to Daniel ;-)

2. Just for reference: Using the older (deprecated) notation for this
example, we have:

    .x($1) { a:$1; b:j; c:k; }
    ..
    <span class="x(i4)"> Doing the same with a "noisy" functional_notation
</span>

I agree with Bert that some user are not mathematically minded.. so I was
only using it as a notational alternative.. I'm expressing an idea
(semantic-notion) the syntactic details can to be improved later on (if idea
is worthy)..

Received on Friday, 24 May 2002 04:47:02 UTC