I think that the last option has the greatest
flexibility because the choice of class names remains
totally in the hands of the author (as it was before). It
even allows authors to select affected content using
expressions other than class names. However, it's much
more complex to achieve, with significant
implications.
To implement this approach, we could simply re-use the
syntax and the linking methods of CSS. All we then need
to do is define a set of CSS properties for each
application (translation, and each microformat), and
allow the specialised user agents to detect them.
This raises more issues, but I think they are easily
solved:
-
Who will define all these new properties and
prevent clashes? — The application developers
will. Each property will belong to a namespace owned
by its definer, and authors wishing to use them will
define a prefix for each namespace. There will be no
need for a central authority beyond the one for
DNS.
Namespace prefixes will be defined using the
existing CSS syntax, and referenced as if vendor
prefixes:
@namespace google "http://google.com/css";
.notranslate {
-google-translate: disabled;
}
…or preferably they would use CSS3 namespace
syntax for type selectors:
@namespace google "http://google.com/css";
.notranslate {
google|translate: disabled;
}
…assuming that's allowed by the lexical grammar of
CSS.
-
Won't regular browsers be downloading lots of
useless CSS rules? — CSS rules for different
applications could be stored in separate files, and
loaded using media queries that only specialised user
agents will recognise. These queries will be
expressed using media types and features with
prefixes chosen by the author to refer to
application-specific namespaces:
<link rel = "schema.google"
href = "http://google.com/css">
<link rel = "stylesheet"
media = "-google-translator"
href = "translation-styles.css">
<!-- or -->
<link rel = "stylesheet"
media = "google|translator"
href = "translation-styles.css">
Again, there's no need for a central
authority.
-
CSS is only for style; won't this break the
separation between content and style that is
considered so valuable? — CSS was designed for
style, but is it really specific to it? The syntax
for selectors is largely independent of its
application, and by exploiting namespace or vendor
prefixes, the set of media types and features you
might use to link in a stylesheet belong to an
extensible set, so you can still keep style separated
from other aspects. And the fact that one writes
<link
rel="STYLESHEET">
is irrelevant —
STYLESHEET is just a mnemonic.
Really, style is just one way of interpreting
content, and in general, you're linking in an
‘interpretation sheet’, not a stylesheet. In other
words, the content-style separation isn't broken by
this proposal; it is merely partitioned further.
The result is a method of designing completely new
ways of interpreting content, not merely rendering it,
without having to wait for an authority to standardize
it, and while leaving choice of class name entirely to
the author, where it should be.
As an example, another mode of interpretation could be
the application of an indexer for a search engine. A
property could be defined to tell search engines not to
index or not to follow certain content within a page:
@namespace search "http://www.w3c.org/2009/search-engines";
.noindex {
search|index: disabled;
}
.nofollow {
search|follow: disabled;
}
In this case, a consortium of search engines could
agree on these properties, without having to affect other
assignments within W3C.
These styles are only relevant to search engines, so
we should inform regular browsers using an appropriate
media query that they don't need to load them in:
<link rel="schema.search"
href="http://www.w3c.org/2009/search-engines">
<link rel="stylesheet"
href="search-styles.css"
media="search|robot">
As well as being more expressive than namespaced class
names (the previous proposal), it also pushes almost all
the namespacing into stylesheets. These are most
effectively used when linked from and shared by many
pages with a common style, so maintenance should be
simpler.
This technique also permits an easy way to migrate a
website using microformats without profiles. The
specifying party of the format writes and publishes an
interpretation sheet for their default class names, and
authors happy to use those default names simply link the
sheet in.