RE: XHTML: Request for easier use of CSS-classes

Hello Reinhard,

"vergiss es!" ;)
(translation for those non-German-speakers on this list: forget it)

> Dear W3C HTML-group members !
>
[cut]
>
> I have one suggestion to your recommendation from the point of a user,
> how writes today HTML documents fast and easy via an text editor.
>
> Please generate a second syntax for the use of CSS classes, which are
> assigned to an HTML element like e.g. 'td'. As my proposal this should
> use the same syntax as used in the CSS via the '.' operator.
>
> Example given for CSS class 'td.t1'
>
>   Normal use:  <td class="t1">
>   Shortcut:    <td.t1>
>
> These should only be an optional shortcut for easier read- and write-
> ability of XHTML documents via an simple text editor.

There are several reasons not to do so:

1. HTML documents now are required to be XML documents. <td.t1> shall
semantically be of the same meaning as <td class="t1">, and this
semantically identical shortcut cannot be done using XML.

2. This selector shortcut will not be backwards compatible. Except for a few
points like names/ids XHTML 1.1 and XHTML Basic 1.0, which base on XHTML
Modularization, are fully backwards compatible.

3. How would you define multiple selectors like <span class="c1 c2 c3"/>?
Probably <span.c1.c2.c3/>, that's where readability suffers a bit again.

4. Imagine a langauge that uses the colon mixed with HTML using the
Namespaces technology, e.g.
<html
  xmlns="http://www.w3.org/1999/xhtml"
  xmlns:s="http://www.somelanguage.org/2001/somelanguage"
>
  <!-- ... -->
    <style type="text/css">
      .x { background-color:green; }
    </style>
  <body>
    <div>
      <s:t.x/>
    </div>
  </body>
</html>
Is t.x now the <t.x/> element of language "somelanguage" or is it the <t/>
element of "somelanguage" using the "x" class?
It is not possible to forbid the '.' to be used in element names because it
is a legal name character. Otherwise it would be impossible to use it as a
shortcut, anyway.

5. All software intended to process HTML would need to be adopted. This is
impossible. HTML is not only processed by web browsers for display, but also
by screen readers for blind people, by documentation software, by XSLT
stylesheets and so on.

6. How would you close such an element, started with <t.x>? Would you use
</t.x> or </t>? This shows more inconsistency: </t.x> would be well-formed
but semantically nonsense because .x is semantically a shortcut for
class="x" and attributes may not be written at end tags. </t> would be
semantically correct but not well-formed XML, so it also would not be used.

I suggest you the following:

use this solution when writing documents yourself and write a little sed or
perl script with a regular expression translating "<t.x/>" into "<t
class='x'/>".
Here is a hint to start with, using VIM-Regex-Syntax:
s/\(<[^\.]\+\)\.\(\a\+\)/\1 class="\2"/g
comment:
search for < followed by a string until a period is found and remember it,
get the word after the period and remember it, for translation into other
languages it is only neccessary to find out wether you must or must not to
escape a certain character like ()+ with \.

A perl script to use this regex looks like this:
#!/usr/bin/perl -p
s/(<[^\.]+)\.([a-zA-Z]+)/\1 class="\2"/g;

A shell script using sh and sed:
#!/bin/sh
sed "s/\(<[^\.]\+\)\.\([a-zA-Z]\+\)/\1 class=\"\2\"/g"

Be warned that this regular expression will go into your CDATA-sections and
do other harm if you use <n.y at some place it is not <n class="y".

Last but not least I am not involved with the W3C, and the points against
<t.d for <t class="d" are just my opinion.
And I hope you can use the regular expressions provided to allow you using
<t.d as shortcut for <t class="d" independantly wether it is standard or
not.
just use the regular expression before looking at the html page.

Greetings

Christian Hujer

> Please can You give me information if it would be possible to define
> such extended XHTML tags on the fly (without a real DTD) to make this
> extension possible and implementable in the various browsers.
>
> I will suggest to insert this as an addition to the XHTML 2.0 family
> and possible Your other - to web sites related - families.
>
> Looking forward to Your answer - many thanks and best regards
>
> Reinhard Häusler
>
>
> P.S.:
> I will send this mail as CC to some web browser developing companies
> and organizations (using the best fitting email address, which I found).
>
> ------------------------------------------------------------------------
>
> Dear CC recipients,
>
> please forward this email to a responsible person or mailing list, which
> can give me respond to the short letter to web browser developers below.
> Thank You and regards
>
> Reinhard Häusler
>
> ------------------------------------------------------------------------
>
> Dear web browser developers,
>
> please give me also Your estimation of the possibility to implement the
> request described in this email. I'm very interested to here, if it is
> easily possible to implement this - as it now seems to be for me.
> Many thanks and best regards
>
> Reinhard Häusler
>
>
>
> SIEMENS			Siemens AG Österreich
> PSE KB C 1			Programm- und Systementwicklung
> Gudrunstraße 11
> A - 1101 Wien
> Reinhard HÄUSLER		Tel. + 43 5 1707 / 46459
> 				Fax  + 43 5 1707 / 55712
> Email (SMTP):		Reinhard.Haeusler@Siemens.at
>

Received on Thursday, 6 September 2001 06:13:07 UTC