...

View Full Version : Stylesheets with <meta> or @import ?



doggo18
09-21-2004, 03:52 PM
Hello all :)

I was looking through some html today, and ran into

<style type="text/css" media="all">@import "/styles.css";</style>
which got me thinking... I myself always use

<link rel="stylesheet" type="text/css" href="comic.css" />

Which of these is preferable to use, and why?

Thanks! :)

bradyj
09-21-2004, 06:19 PM
the import method can be useful if you want to import multiple style sheets into one section... but most importantly, importing hides styles from older browsers -- the link tag does not. I prefer the links myself, just because it isn't as fickle for me right now and it looks cleaner to me because I'm anal about how code looks (you can do multiple ways of importing that some browsers will not read, which can be useful, read below), and you can also import into a linked external file... meaning, you make your external CSS file, and link it to your document (the meta way) but in that file put an import -- this is a trick some designers use so they can still use the link tag for javascript style switchers, but still hide the junk from old browsers, take a look at simplebits.com's file:
simplebits css (http://www.simplebits.com/css/styles.css)
simplebits home (http://www.simplebits.com) (look at his home page code, you can link alternate styles as well)

And here's a bit about import options and what browsers read what:
http://w3development.de/css/hide_css_from_browsers/import/

This is my take on it, some other users will have some better ideas:)

doggo18
09-21-2004, 07:22 PM
Ok thanks!

I'll stick to the link method for now.. Looks better :D

mindlessLemming
09-21-2004, 10:48 PM
but most importantly, importing hides styles from older browsers -- the link tag does not.

Not quite...
The link stylesheet won't be used by NN4.7 unless the media attribute is set as "all". Since there is almost never a reason to use media="all" it's quite simple to hide it from nn4.7.
Designing for the screen? use media="screen, projection" (projection is for Opera's full screen mode - thanks brothercake ;))
Designing for print? use media="print"
Handheld? media="handheld"

... there would be very few cases when you would want the same CSS file used for all these media.

AaronW
09-22-2004, 12:05 AM
I'd use <link media="all" /> for my styles that are renderable by even the baddest of browsers, and then @import "style.css" for my styles that are meant for more capable browsers (IE5+, Moz)

gwendaal
09-23-2004, 07:25 AM
but who care for NN4.7 ????

bradyj
09-23-2004, 05:35 PM
but who care for NN4.7 ???? I don't, I don't even code for it anymore -- but sometimes I just like to hide it from older browsers so they just get a simple text version, that's all. I see NN4 just like a screenreader or a handheld -- they get all my information, it just isn't styled like the advanced browsers.

mindlessLemming
09-24-2004, 02:00 AM
I see NN4 just like a screenreader or a handheld -- they get all my information, it just isn't styled like the advanced browsers.
I'd like to do the same for IE/mac, it's just too much of a pain to filter it properly :mad:

AaronW
09-24-2004, 02:35 AM
@import "style.css" hides from IE/Mac 4.01 or something like that, according to that link Brady posted. I've not had any problems on IE5 for the Mac... It's better than the Windows version is it not?

mindlessLemming
09-24-2004, 03:01 AM
@import "style.css" hides from IE/Mac 4.01
ie4?! Who cares about ie4?? :eek:

It's better than the Windows version is it not?
You've got me there - the rendering engine (trident?) was the top of it's time... I'm biased against it though - I've never had enough time to test bugs properly on it and the fact that it has a very different bug set than the windows version makes me want to put it in the NN4.7 bin. Brady insisting that no one uses it anymore isn't tempting me to stop ignoring it either :o

]|V|[agnus
09-24-2004, 03:23 AM
The rendering engine is called Tasman.

bradyj
09-24-2004, 03:51 AM
Brady insisting that no one uses it anymore isn't tempting me to stop ignoring it either :o

You're only hurting yourself, just let it go...

gsnedders
09-24-2004, 09:01 AM
You might as well use Lynx ;)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum