CSS selectors in web pages
jeroen at linuxfromscratch.org
Sun Sep 19 22:32:49 PDT 2004
Nico R. said the following on 19-09-2004 19:33:
> Jeroen, I hit a problem here: each clickable link in the styleswitcher
> currently has 3 pieces of information connected with it:
> a) the name of the style to activate (same as the title attribute of the
> link element to the stylesheet),
> b) the value for the title attribute of the li element in the
> styleswitcher (this text will usually be presented to the user as a
> c) the text that is displayed and on which the user clicks to select
> that particular style.
> a) can be extracted from the DOM, no problem here.
> b) and c) don't exist in the DOM (link element), so we're running into a
> problem here.
Well, the tooltip is optional and extra, so I'd have no problem if it
were optional. The only relevant information which could be used would
be the filename of the stylesheet. But no title is OK too.
> I *could* write something that uses c) as the title of the link element.
> The advantage would be that the web page and the *browser* menu for
> stylesheet selection (which is present in many browsers, e.g. Firefox,
> Konqueror) use the same text. The downside is that it would break
> existing cookies! And we couldn't change those texts anymore, once they
> have been introduced, without breaking our users' cookies.
Breaking the cookies: we'd only change names if we switch to the new site.
Would it also be possible to determine where in the page that the
stylesheet would be placed? Perhaps by some <div id=""> which is in the
> It would be possible to create some kind of fallback, though: an array
> of stylesheet names and the other info the script needs (like that
> patch I sent earlier) which is used to extract the necessary info. If
> it does not exist, we fall back to the default value (the value of the
> title attribute of the link element) and no title element for the
> hyperlinks (or a title computed from the link title).
As long as it's only a fallback, I don't have a problem with it.
> The advantage of this method is that it'll always work, not break
> existing cookies (if not combined with the solution for c) above), but
> it will still need the array in the script. An additional advantage is
> that all stylesheets will be used that are present in the DOM via link
> elements. So each page can have individual styles assigned to it; the
> master script file styleswitcher.js needs descriptions for all of them.
More information about the website