I confess, I don't know how to do this (@import)

Megan's picture

She has: 11,421 posts

Joined: Jun 1999

I get the general impression from this an other forums that I'm supposed to use @import to serve different stylesheets to NS 4 & newer browsers. Problem is that I honestly don't know how to do this. You got me - I don't know! I even looked on some styleheet references and a google search and didn't come up with much. I guess since everyone already knows this there's no need to explain it in tutorials or anything.

So, anyway, what's the code for this? I did find one bit that went something like this:

@import "styles.css";

But it doesn't work. Suggestions?

He has: 1,016 posts

Joined: May 2002

I beleive it's @import url("file.css");

PS. Don't tell anyone, but I didn't know it either. I remember I saw it in the phpBB2 template so that's where I checked right now Laughing out loud

Suzanne's picture

She has: 5,507 posts

Joined: Feb 2000

@import "otherstyles.css";

Taken directly from my personal site, where I know they work. Smiling

The best idea with @import is to use it only for advanced styles that break lower browsers.

However, here's a page with all the various ways to hide CSS from different browsers.

http://www.ericmeyeroncss.com/bonus/trick-hide.html

There, Eric uses this:

@import url(http://www.example.org/styles/adv-style.css);

Megan's picture

She has: 11,421 posts

Joined: Jun 1999

Thanks, zollet, that seems to be what I'm looking for Smiling I'm glad to know that I wasn't the only one who was in the dark about that one.

He has: 1,016 posts

Joined: May 2002

Noone can know everything. I've been creating websites for 7 years now and I've tried most languages and programs and not one day goes by when I don't look something up in a book or on the net. It takes me a few seconds to look things up instead of sitting there wasting time trying to remember everything and making mistakes. Time is money, I'm sure you already know that Smiling

PS. Half the time Mark is correcting my SQL queries and there's no hard feelings here (I simply submit his email to gay mailinglists Laugh but don't tell him, muhahahaah!!!) j/k

Laughing out loud

Megan's picture

She has: 11,421 posts

Joined: Jun 1999

It's not really that - I had just gotten the impression through other comments here and elsewhere that this code in particular was something easy and obvious that everyone knows, which is why I felt bad about having to ask. And I couldn't find anything on reference sites so I figured it must be something so widespread that it didn't even need to be explained. I was feeling like I was the only dummy who didn't know @import. So, thanks Smiling

Abhishek Reddy's picture

He has: 3,348 posts

Joined: Jul 2001

Quote: I was feeling like I was the only dummy who didn't know @import

Thanks for asking. Now I know what @import is, and I didn't even have to ask. Laughing out loud Wink

Megan's picture

She has: 11,421 posts

Joined: Jun 1999

Cool! That makes three of us! I guess we can be thankful that we have someone around here that knows these things. Thanks Suzanne and Zollet for letting us in on that one Smiling

The Webmistress's picture

She has: 5,586 posts

Joined: Feb 2001

And be glad that we have you here Megan to ask the questions that the rest of us are too scared to ask! Wink lol

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.