- From: Bert Bos <bert@w3.org>
- Date: Thu, 16 May 2002 18:23:45 +0200
- To: Alberto Pacheco <alberto@computer.org>, www-style@w3.org
Daniel Glazman writes: > Alberto Pacheco wrote: > > > Does CSS support the following class descriptors functionality? > > > > 1) Adding classes > > Let be > > .a { p1; } > > .b { p2; } > > How do I get ".c {.a + .b}" or "<span class=a+b>" > > Where class c combines a & b classes properties, ie equivalent to > > ".c { p1; p2; }" > > > Just write <span class="a b">. > > > 2) Parametrized classes > > How do I get something like: > > .c(X,Y) { width:X; color:Y; } > > To be refered in HTML later as: > > <span class="c(50%,red)"> > > Where class c becomes equivalent to ".c { width:50%; color:red;)" > > > > I know it sounds crazy.. > > > Oh ! That one is interesting and not so crazy. We already have > pseudo-classes accepting parameters, so why not classes (theoretical > question only)... > Unfortunately it's not only on the CSS side and would imply a > modification of the class attribute's model. > Anyway, I think it deserves to be added to the CSS Suggestions List, if > it is still active. Bert, what do you think ? With respect to the list of suggestions: yes, I am still adding things to it, but since there are no current plans for publication of another draft, that document is only visible to W3C members for now. As for the idea of parametrized classes: it is an interesting idea, but I'm not sure it is the direction we should go. Normally, when you have a flexible syntax for expressing document structure, such as SGML/XML, it is a good idea to try to stay within the syntax as much as possible. In this case, it seems that parameters should be expressed as attributes in XML, unless it is clear that that would look too ugly. Also, there already is a "style" attribute in several formats, which is the place to put stylistic information. In general, it is better to keep stylistic info out of the document, but when it is needed, it is better to put it in one, dedicated attribute, and not mix it with other mark-up. There is a reason HTML doesn't have attributes for width and color: they already have their place in the style sheet. Conversely, if you find that you need them in the document, then maybe HTML is not the format you are looking for. Finally, there is the issue of usability. For some people, parameters are easy to understand, because they use them in other contexts, but many others are not so mathematically minded and will not understand the concept of variables that become instantiated. Even for more advanced users, it will be hard to work out exactly what the role is of a class's arity and the types of its parameters in matching a selector and in applying the cascading rules. We have the attr() functional notation, which could in principle be generalized to copy the value of any attribute to the right hand side of style rules. But I'm not a big fan of that either. I like a much cleaner separation: everything that appears in a document, including element names, attribute names, attribute values and element content, should only ever appear in the selector part of a style rule. The selectors are the glue, or the interface, between the document and the style sheet. The properties live in a different world, where the document has been abstracted away, and we are only dealing with an abstract, more or less tree-structured rendering structure that has nothing to do with SGML or XML. So, to take your example, my first question would be: are you really sure that this is the best possible expression of your intentions? Do you really want this element to be 50% wide and red in all circumstances, or is that style just a particular way of expressing the abstract meaning of the element, that could also be expressed differently. Can you really not come up with a keyword to express the meaning of the element ("topic," "important," "sidenote," "teaser," "counterexample," "ironic"...)? If you find that the style is indeed a fundamental aspect of the element, then maybe HTML is not the language you are looking for. In the TEI format, e.g., you can express that a certain word or phrase appears in a certain style. This may be important, e.g., if you are comparing two prints of an old book. (Literature study is one of the applications of TEI.) If you just want to fix the style of an element from within the document for reasons of experimentation or because you are in the midst of rearranging your documents and style sheets, then there is the "style" attribute of HTML. It is hardly less powerful than your parameters. Bert -- Bert Bos ( W 3 C ) http://www.w3.org/ http://www.w3.org/people/bos/ W3C/INRIA bert@w3.org 2004 Rt des Lucioles / BP 93 +33 (0)4 92 38 76 92 06902 Sophia Antipolis Cedex, France
Received on Thursday, 16 May 2002 12:24:22 UTC