Forum Moderators: not2easy

Message Too Old, No Replies

Alternate Style Sheets

Possible to use the @import method?

         

Reflection

7:53 pm on Jul 17, 2003 (gmt 0)

10+ Year Member



I cant seem to find this information anywhere, if its possible how do you declare an alternate style sheet using the @import method rather than link rel method?

Thanks.

hakre

8:12 pm on Jul 17, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



hi!

this is just a quick shot, but maybe the right way:

@media print
{
@import ...
}
@media screen, handheld
{
@import ...
}

- hakre

TheDoctor

8:14 pm on Jul 17, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Not sure what you mean by "alternate".

But you can specify a style sheet by putting


<style>
@import stylesheet.css
</style>

in the "head" part of the page (where you replace "stylesheet.css" with your own style sheet name, of course).

This means that your styles will not be applied when the browser is NN4.x

Reflection

8:20 pm on Jul 17, 2003 (gmt 0)

hakre

8:35 pm on Jul 17, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



i see, thanks for the note.

the one i thought about (just to complete) is documented here (css2) [w3.org] (the one posted first does the same):

@import url("fineprint.css") print;
@import url("bluish.css") projection, tv;

unfortunately, i can't tell you how to do. in my opinion the link-version is a css1 spec whereas @import a css2 spec is. in css2 i was not able to find the alternative stylesheet - there are other mechanisms to wieght between author and user. correct me please if i'm wrong.

-hakre

drbrain

9:21 pm on Jul 17, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



No, you must use <link>.

You can, however, @import styles from there.

Reflection

9:38 pm on Jul 17, 2003 (gmt 0)

10+ Year Member



Thats what I was beginning to think after I couldnt find any examples or documentation using @import.

Thanks drbrain.

hakre

9:40 pm on Jul 17, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



reflection, search the w3c page and you'll get a lot @import in the css2 section.

-hakre

annej

11:00 pm on Jul 17, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I want to set things so netscape 4 won't try to pick up my CSS from the style sheet.

<LINK rel=stylesheet type="text/css" HREF="stylesheet.css"> works but it includes NS4.

I've tried the following two but then even the new browsers don't pick up my stylesheet

<style> @import stylesheet.css </style>

<style type="text/css"> @import ("stylesheet.css"); </style>

I must be missing something. Someone mentioned you still need link but I don't know how to write the code.

Any help you be great.

Thanks

Reflection

11:09 pm on Jul 17, 2003 (gmt 0)

10+ Year Member



NN4 only understands a media type of screen. So for your nn4 style sheet set the media to screen and for others you can use media all.

NN4
<link rel="stylesheet" type="text/css" media="screen" href="styles/basic.css">

Others
<link rel="stylesheet" type="text/css" media="all" href="styles/main.css">

OR
<style type="text/css" media="screen">@import "styles/main.css";</style>

nowhereMan

5:58 am on Jul 18, 2003 (gmt 0)

10+ Year Member



I am using the @import for my stylesheets and it works fine. NS4 doesn't use the stylesheets at all.

<style type="text/css">
@import url(styles/style.css);
</style>

/ m a r t i n

MTKilpatrick

1:57 pm on Jul 18, 2003 (gmt 0)

10+ Year Member



I've heard that some browsers are buggy in that they complain if the import statement isn't on its own line.

In my own website I do exactly this:

<style type="text/css" title="User Defined Style">
@import "css/php_main.css";
</style>

Note that setting the title attribute of the style tag enables you to set "Use Stylesheet" to "none" in Netscape. Without naming the stylesheet, you can't do it. I hope that helps.

Michael

annej

3:23 pm on Jul 18, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Martin's solution worked for me! I must have had something else in my style sheet or on the HTLM page that messed up the other solutions.

One of the big challenges for me is that there are so many ways to do things with CSS.

Thanks everyone.