D&C Lug - Home Page
Devon & Cornwall Linux Users' Group

[ Date Index ][ Thread Index ]
[ <= Previous by date / thread ] [ Next by date / thread => ]

An overdue reply on CSS (was Re: [LUG] CSS reference extended, as requested)



Date: Wed, 25 Jun 2003 01:35:15 +0100
Simon W wrote:
> Silly question time, but Mozilla offers an option for loading different
> style sheets "View > Use Style".
> 
> The docs suggest these are style sheets that are "LINK"ed from the
> original page (server provided?).
> 
> Do you have an example? Have you tried this? Can I have codehelp with
> bigger text this way? Does any other browser play this game? Can I
> specify my own style sheets, should Iever master them.

OK, I now have the answers and what's more, some of the examples are 
implemented too.

The docs are correct, it is possible to provide multiple style-sheets from any 
HTML page by repeating the <link href="" type="stylesheet" media=""> tag. The 
key is the media attribute and this can get VERY confusing.

The media attribute can take multiple values BUT browsers vary on how they 
implement this. e.g. 

I originally set the DCLUG pages to implement multiple style sheets because of 
the black background when it came to printing pages. I set one stylesheet for 
the default and one to change the background to white and the blue border to 
silver. When I mimicked this in the media attribute, I tried to give Simon an 
example of selectable multiple stylesheets by allowing users to select the 
'print' stylesheet from the browser. Simple? No. The browser displayed the 
print stylesheet OK, but didn't PRINT the print stylesheet - it made a bodge 
and trashed the page entirely on the printout. (Konqueror + Mozilla).

After MUCH faffing around and swearing at the W3C site (which is not entirely 
crystal clear on how these things are meant to work in real browsers), I had 
to compromise - the second stylesheet for printing now works behind the 
scenes. It isn't selectable but it is used by all compliant browsers to 
create a printable page with correct colours, smaller Serif fonts (more 
suitable for print, according to W3C) etc.

So: Simon, your answers.

1. Yes, these additional stylesheets must be written by the page composer and 
be provided via explicit links in the specific page and then by the server 
upon request from the browser. (This means that, possibly, printing a DCLUG 
page while OFFLINE could now fail. Hmm.) Other mechanisms exist for users to 
write their own stylesheets but the power of these will be extremely limited 
- it would require a LOT of work to do more than basic changes to the page 
formatting.

2. The example isn't particularly obvious, but yes, there are 7,000 examples 
in the source code of the entire DCLUG page - every page now has the double 
stylesheet format. Only for printing though, there is still only one for the 
WWW GUI browsers.

3. Yes, I've tried it and yes I've learnt a lot of new swearwords.

4. Yes, you can but not yet. I haven't decided what I would want to achieve at 
codehelp from the media attribute (if anything, it would be a smaller font 
more suitable for printing). I have got a few pages that use this, but there 
are other areas that need work before I delve further into this particular 
topic. I also have problems describing the media attribute on the site as 
support is flaky at times and it will take a lot more experimentation before 
I can give a reliable summary of what can and cannot be done. There was a 
clearer need for this feature at DCLUG (and even that need wasn't 
particularly crucial).

5. All browsers that fully implement HTML4 and CSS1 should implement it, but 
as yet I'm having problems seeing just how each one has interpreted the 
implementation! Currently, I get different results in Konqueror to Mozilla in 
some areas - neither is right or wrong, just different. This means a return 
to the bad old days of duplicate methods to cover all browsers.

I do have one example on the codehelp site (just uploaded it tonight):
http://www.codehelp.co.uk/query/glossaryA.shtml

One VERY interesting feature of the media attribute is that it is STICKY. If 
two or more linked stylesheets have the same media setting, the browser is 
meant to retain your choice of stylesheet WHEN YOU CHANGE PAGES. Select the 
alternative print view, then move to any other page. No other page on 
codehelp has the additional tag as yet, but now return to the A page and hey 
presto, it should snap back to print view - even when your refresh the page. 
(Spookily, in Konqueror it even does this when going from a LOCAL page to the 
INTERNET page!!)

So it must become part of the HTTP headers somehow and be passed on to the 
next request. Once implemented, this would allow users to select the 
stylesheet on the index page and browse the entire site in their preferred 
environment -  even have the browser remember which stylesheet to use 
throughout the entire browser session, even if the user moves on to lots of 
other unrelated sites. Very powerful - cookie like behaviour, without the 
server being any the wiser.

The media attributes are:

screen
print
projection
handheld
tv
tty
aural
braille
embossed
all

Screen is the only one to allow the browser behaviour that Simon first 
noticed. The principle should be the same for aural browsers too and the idea 
of braille is fascinating.
TV is there to allow pages to reformat for the narrow, tall screens of TV 
layout.
print also includes mechanisms to dictate where page breaks are inserted, 
dictate paper sizes and formats (portrait or landscape) and whether to print 
double-sided, even or odd pages only, booklet form, and a few others. Browser 
support for actually getting the printer spool to listen is at best patchy.

Page breaks are also meant to be implemented for projection and some of the 
others too, IIRC. More details on the W3C CSS2 pages.
http://www.w3.org/TR/REC-CSS2/media.html


-- 

Neil Williams
=============
http://www.codehelp.co.uk
http://www.dclug.org.uk

http://www.biglumber.com/x/web?sn=Neil+Williams

Attachment: pgp00009.pgp
Description: signature


Lynx friendly