This is Interesting: Free Magazines for Graphics designers and webmasters  


Home > Archive > Stylesheets > March 2007 > When are alternate stylesheets invoked?





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author When are alternate stylesheets invoked?
johkar

2007-03-16, 11:16 pm

I need some browser implementation clarification.

In the below example, the alternate stylesheet could be invoked by
user agents that support alternate stylesheets or by script. Are
there any browsers that don't recognize "alternate stylesheet" as a
value of the rel attribute and just implement it automatically thus
overriding sheet2.css? Just need to know what I need to worry about.

<link href="sheet1.css" rel="stylesheet" type="text/css"
id="default1" />
<link href="sheet2" rel="stylesheet" type="text/css" id="default2"
title="Default" />
<link href="sheet3.css" rel="alternate stylesheet" type="text/css"
id="print" title="Print" />

Thanks

Andreas Prilop

2007-03-16, 11:16 pm

On Fri, 16 Mar 2007, johkar wrote:

> In the below example,


Make a sample page and post the URL here!

> Are
> there any browsers that don't recognize "alternate stylesheet" as a
> value of the rel attribute


Internet Explorer 6.

> <link href="sheet3.css" rel="alternate stylesheet" type="text/css"
> id="print" title="Print" />


"alternate stylesheet" specifically for print is nonsense.
And, btw, the slash before the final > is also nonsense.

--
In memoriam Alan J. Flavell
http://groups.google.com/groups/sea...:Alan.J.Flavell
johkar

2007-03-16, 11:16 pm


Andreas Prilop wrote:
> On Fri, 16 Mar 2007, johkar wrote:
>
>
> Make a sample page and post the URL here!
>
>
> Internet Explorer 6.
>
>
> "alternate stylesheet" specifically for print is nonsense.
> And, btw, the slash before the final > is also nonsense.
>
> --
> In memoriam Alan J. Flavell
> http://groups.google.com/groups/sea...:Alan.J.Flavell


Could you please expand on your answer regarding it being nonsense for
"alternate stylesheet" being used for print? I am totally open to
best practices, but there doesn't seem to be consensus on how best to
implement printable pages. Some camps of experts appear to dislike
using print media...probably more for usability reasons. Enlighten
me.

Thanks

Andreas Prilop

2007-03-16, 11:16 pm

On Fri, 16 Mar 2007, johkar wrote:

>
> Could you please expand on your answer regarding it being nonsense for
> "alternate stylesheet" being used for print?


Just use
<link rel="StyleSheet" media="print" ......
for printing.
http://www.htmlhelp.com/reference/css/style-html.html

There's no need for "Alternate Stylesheet" here - unless you want
*two* different printing stylesheets.

--
In memoriam Alan J. Flavell
http://groups.google.com/groups/sea...:Alan.J.Flavell
Vid the Kid

2007-03-19, 4:16 am

johkar wrote:
> I need some browser implementation clarification.
>
> In the below example, the alternate stylesheet could be invoked by
> user agents that support alternate stylesheets or by script. Are
> there any browsers that don't recognize "alternate stylesheet" as a
> value of the rel attribute and just implement it automatically thus
> overriding sheet2.css? Just need to know what I need to worry about.
>
> <link href="sheet1.css" rel="stylesheet" type="text/css"
> id="default1" />
> <link href="sheet2" rel="stylesheet" type="text/css" id="default2"
> title="Default" />
> <link href="sheet3.css" rel="alternate stylesheet" type="text/css"
> id="print" title="Print" />
>
> Thanks
>


Alternate stylesheets can be invoked by scripts, yes, but they are
normally invoked directly by the user through some kind of browser
command. In the code you cited, sheet1.css and sheeet2 (assuming they
are served with the correct MIME type despite the second not having a
file extention) would actually be combined, according to CSS cascading
rules. Sheet3.css would be invoked by the user selecting the "Print"
alternate style from their browser menu.

If you want to have a print stylesheet invoked automatically when a
document is printed, use:
<link href="print.css" rel="stylesheet" type="text/css" id="print"
title="Print" media="print" />

The default value for the media attribute is "all", so any stylesheets
included with no media specified will also be used for printing. Again,
conflicts between stylesheets are resolved by CSS cascade rules.

--
David "Smith"
a.k.a. Vid the Kid

Does this font make me look fat?
Bergamot

2007-03-20, 12:06 am

Vid the Kid wrote:
>
> Alternate stylesheets can be invoked by scripts, yes, but they are
> normally invoked directly by the user through some kind of browser
> command.


I believe, however, that browsers tend to pre-load the alternate
stylesheets along with the default(s). Those rules just aren't applied
until requested. I mention this because there's been some question in
the past about when a browser actually retrieves an alternate stylesheet.

> <link href="print.css" rel="stylesheet" type="text/css" id="print"
> title="Print" media="print" />


I'm curious - what purpose does the id attribute serve here? I've never
used it on stylesheets before.

--
Berg
-Lost

2007-03-21, 4:19 am

"Bergamot" <bergamot@visi.com> wrote in message news:567dovF27m35fU1@mid.individual.net...
> Vid the Kid wrote:
>
> I believe, however, that browsers tend to pre-load the alternate
> stylesheets along with the default(s). Those rules just aren't applied
> until requested. I mention this because there's been some question in
> the past about when a browser actually retrieves an alternate stylesheet.
>
>
> I'm curious - what purpose does the id attribute serve here? I've never
> used it on stylesheets before.


Outside of an accessing script, I believe there is no purpose.

http://www.w3.org/TR/html4/struct/links.html#h-12.3

Calls its use a "document-wide identifier." And:

http://www.w3.org/TR/html4/struct/g...ml#id-and-class

Refers to it as a style sheet selector, and a means to reference a particular element from
a script.

-Lost


johkar

2007-03-29, 4:18 am

On Mar 19, 8:22 am, Bergamot <berga...@visi.com> wrote:
> Vid the Kid wrote:
>
>
> I believe, however, that browsers tend to pre-load the alternate
> stylesheets along with the default(s). Those rules just aren't applied
> until requested. I mention this because there's been some question in
> the past about when a browser actually retrieves an alternate stylesheet.
>
>
> I'm curious - what purpose does the id attribute serve here? I've never
> used it on stylesheets before.
>
> --
> Berg


Sorry, I have been absent after my original post. I realize you can
use media=print, but some usability gurus poo poo this idea...there
seems to be two camps. One camp advocates using media=print and the
other wants to invoke stylesheet switching either using JavaScript or
the server to show the printable page to the user in a new window.

There can be much debate over which to do. One question which has not
really been addressed is when did "alternate stylesheet" become a
valid value for the rel attribute...and what is the browser support
for it? I realize that could be a question for the HTML newsgroup,
but there is some crossover.

Andreas Prilop

2007-03-29, 7:18 pm

On Thu, 28 Mar 2007, johkar wrote:

> I realize you can
> use media=print, but some usability gurus poo poo this idea...


References?

> One question which has not
> really been addressed is when did "alternate stylesheet" become a
> valid value for the rel attribute...


In CSS level 1, i.e. 1996.
http://www.htmlhelp.com/reference/c...l.html#external

> and what is the browser support for it?


Internet Explorer 6 fails - real browsers support alternative
stylesheets.

> I realize that could be a question for the HTML newsgroup,


No, this is the right group.

--
In memoriam Alan J. Flavell
http://groups.google.com/groups/sea...:Alan.J.Flavell
Bergamot

2007-03-29, 7:19 pm

johkar wrote:
> On Mar 19, 8:22 am, Bergamot <berga...@visi.com> wrote:
>
> I realize you can use media=print,


Am I reading your response wrong, or did you read my question wrong? :)

> but some usability gurus poo poo this idea...


This is the first I've heard that opinion. I use print stylesheets all
the time.

> One camp advocates using media=print and the
> other wants to invoke stylesheet switching either using JavaScript or
> the server to show the printable page to the user in a new window.


The latter is the way things were done before print stylesheets had any
real support. Why continue an outdated practice if you don't have to?
It's just more work, and I don't see any benefit to the user.

BTW, you don't need a separate stylesheet just for print. You can also
use @media rules within a common stylesheet. This is my preferred way of
setting print rules.

@media screen, projection {rules}
@media screen, projection, print {rules}
@media print {rules}

The navigation menu styling, background images and other screen-only
things are in the first group. General content formatting is usually in
the second group. The last group sets display:none on the navigation
menu and other things that shouldn't be printed and occasionally has
some extra styling just for print.

It works for me. YMMV

--
Berg
Sponsored Links


Copyright 2003 - 2008 forum4designers.com  Software forum  Computer Hardware reviews