Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / HTML, CSS, Scripts / CSS / March 2007



Tip: Looking for answers? Try searching our database.

When are alternate stylesheets invoked?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
johkar - 16 Mar 2007 16:47 GMT
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 - 16 Mar 2007 16:52 GMT
> 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.

Signature

In memoriam Alan J. Flavell
http://groups.google.com/groups/search?q=author:Alan.J.Flavell

johkar - 16 Mar 2007 17:09 GMT
> > In the below example,
>
[quoted text clipped - 15 lines]
> In memoriam Alan J. Flavell
> http://groups.google.com/groups/search?q=author: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 - 16 Mar 2007 17:24 GMT
>> "alternate stylesheet" specifically for print is nonsense.
>
> 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.

Signature

In memoriam Alan J. Flavell
http://groups.google.com/groups/search?q=author:Alan.J.Flavell

Vid the Kid - 19 Mar 2007 08:59 GMT
> I need some browser implementation clarification.
>
[quoted text clipped - 12 lines]
>
> 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.

Signature

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

Does this font make me look fat?

Bergamot - 19 Mar 2007 13:30 GMT
> 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.

Signature

Berg

-Lost - 21 Mar 2007 05:27 GMT
>> Alternate stylesheets can be invoked by scripts, yes, but they are
>> normally invoked directly by the user through some kind of browser
[quoted text clipped - 10 lines]
> 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/global.html#id-and-class

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

-Lost
johkar - 29 Mar 2007 04:36 GMT
> > Alternate stylesheets can be invoked by scripts, yes, but they are
> > normally invoked directly by the user through some kind of browser
[quoted text clipped - 13 lines]
> --
> 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 - 29 Mar 2007 14:29 GMT
> 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/css/style-html.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.

Signature

In memoriam Alan J. Flavell
http://groups.google.com/groups/search?q=author:Alan.J.Flavell

Bergamot - 29 Mar 2007 19:03 GMT
>> > <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 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

Signature

Berg

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.