By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,493 Members | 1,920 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,493 IT Pros & Developers. It's quick & easy.

When are alternate stylesheets invoked?

P: n/a
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

Mar 16 '07 #1
Share this Question
Share on Google+
9 Replies


P: n/a
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/sear...Alan.J.Flavell
Mar 16 '07 #2

P: n/a

Andreas Prilop wrote:
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/sear...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

Mar 16 '07 #3

P: n/a
On Fri, 16 Mar 2007, johkar wrote:
>"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.

--
In memoriam Alan J. Flavell
http://groups.google.com/groups/sear...Alan.J.Flavell
Mar 16 '07 #4

P: n/a
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?
Mar 19 '07 #5

P: n/a
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
Mar 19 '07 #6

P: n/a
"Bergamot" <be******@visi.comwrote in message news:56*************@mid.individual.net...
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.
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/gl...l#id-and-class

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

-Lost
Mar 21 '07 #7

P: n/a
On Mar 19, 8:22 am, Bergamot <berga...@visi.comwrote:
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
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.

Mar 29 '07 #8

P: n/a
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/cs....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/sear...Alan.J.Flavell
Mar 29 '07 #9

P: n/a
johkar wrote:
On Mar 19, 8:22 am, Bergamot <berga...@visi.comwrote:
>Vid the Kid wrote:
<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

--
Berg
Mar 29 '07 #10

This discussion thread is closed

Replies have been disabled for this discussion.