Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-23-2008, 02:29 PM   PM User | #1
BoldUlysses
Regular Coder

 
BoldUlysses's Avatar
 
Join Date: Jan 2008
Location: Winston-Salem, NC
Posts: 938
Thanks: 10
Thanked 190 Times in 187 Posts
BoldUlysses is on a distinguished road
Pros and cons of importing

I've seen two ways to reference external style sheets, @import and link/href. What would be the advantage/disadvantage of

Code:
<style type="text/css" media="screen, projection">@import "main.css";</style>
versus

Code:
<link href="main.css" rel="stylesheet" type="text/css"/>
?

Just want to make sure I do things the most standards-compliant way.
BoldUlysses is offline   Reply With Quote
Old 05-23-2008, 02:50 PM   PM User | #2
jhaycutexp
Regular Coder

 
Join Date: Apr 2008
Location: Manila, Philippines
Posts: 249
Thanks: 2
Thanked 12 Times in 12 Posts
jhaycutexp is an unknown quantity at this point
import css is when you have two external style sheets... for example a page has two style sheets, one is for the general browsers.. and the second one for hacks... but most i see in that format is when one for ie browsers and the other one, for ff and other css compliant browsers..
jhaycutexp is offline   Reply With Quote
Old 05-23-2008, 03:28 PM   PM User | #3
Candygirl
Regular Coder

 
Candygirl's Avatar
 
Join Date: Apr 2008
Location: Switzerland
Posts: 181
Thanks: 3
Thanked 55 Times in 55 Posts
Candygirl is on a distinguished road
@import is not understand by old browsers. It can be useful to hide your css for those browsers to prevent the sites being hard or impossible to watch because of css properties poorly or not interpreted.

Here is some pages with different syntaxes regarding of which browser can read it or not: http://imfo.ru/csstest/css_hacks/import.php or http://centricle.com/ref/css/filters/

The one you've written is a good one to prevent generation 4 browsers to read the css. For exemple, the way we use css today can really be nasty in netscape 4.x. Now the question might be: are they really some people still using IE or NS 4.x ?

More generally @import could be useful to call a stylesheet from another stylesheet, link to use alternate stylesheets.
I've read some intervention about bad performances using imbrication of @import.
__________________
"Imagination was given to man to compensate for what he is not;
a sense of humour to console him for what he is."
-Francis Bacon

Last edited by Candygirl; 05-23-2008 at 03:35 PM..
Candygirl is offline   Reply With Quote
Old 05-23-2008, 04:12 PM   PM User | #4
Apostropartheid
The Apostate


 
Apostropartheid's Avatar
 
Join Date: Oct 2007
Posts: 3,215
Thanks: 16
Thanked 265 Times in 263 Posts
Apostropartheid is on a distinguished road
I prefer the link method. I don’t particularly enjoy style blocks or inline styles. As said, not many people still use such old browsers and if they do they’re probably really used to see terrible layout by now.
__________________
Blog | Twitter
Useful links: W3C HTML Validator | W3C CSS Validator | HTML 5 Guide
CF: HTML & CSS Resources/Tutorials Thread | HTML & CSS Posting Rules and Guidelines
Remember: no link, no code, no help!
Apostropartheid is offline   Reply With Quote
Old 05-23-2008, 04:13 PM   PM User | #5
BoldUlysses
Regular Coder

 
BoldUlysses's Avatar
 
Join Date: Jan 2008
Location: Winston-Salem, NC
Posts: 938
Thanks: 10
Thanked 190 Times in 187 Posts
BoldUlysses is on a distinguished road
Ah ha... Thanks. I just use a conditional comment to call alternate style sheets:

Code:
<!--[if IE]>
<link href="ie.css" rel="stylesheet" type="text/css"/>
<![endif]-->
Seems to take the guesswork out of knowing which browser will read it and which won't, without the online references.

How many people are using the older browsers really is the question. I code for IE6, 7, FF, Safari and Opera and call it a day.
BoldUlysses is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:06 PM.


Advertisement
Log in to turn off these ads.