Hello.
I've seen a few other websites which actually do this, but I wasn't sure whether it's a) "OK", b) whether some browsers wouldn't support it.
Basically, in the HTML itself within the head they have:
<style type="text/css" media="all">@import url('/css/foo.css');</style>
Then, /css/foo.css just contains one line:
@import url('/css/3rdoct04.css');
Is this generally a bad idea?
I'd really like to use this, as it's much easier for me to just edit "foo.css" instead of the HTML itself.
Thanks. Yeah, that's one way, you can also use:
<link rel="stylesheet" type="text/css" href=http://www.webdeveloper.com/forum/archive/index.php/"foo.css" />
but you don't need to import it again in foo.css, you can just put all the CSS stuff there.Hi, thanks for your reply.
Yes, I'm aware of this.
If you re-read my post you'll see why I want to do it that way...It's a good idea to use the LINK tag for importing CSS, however NS4 understands it, to an extent, and usually doesn't look too great. So, it's probably best to use the LINK tag to an import.css file, which imports the main stylesheet file. If you use single-quotes in your import statement, I believe IE5/Mac won't get the stylesheet, either.Opera seems to have a problem when importing styles like so: @import "styles.css";. However, if I use the LINK element to reference a stylesheet, and have only one line in the stylesheet, the import line, then Opera gets it just fine. I don't see why you would want to change the style sheet filename thoughTeach - @import is used in place of <link> in order to hide the stylesheet from earlier browsers which poorly support CSS.Hiya.
Thanks for your replies.
Let me explain my original query a bit more clearly - I don't think I said it very clearly as no one has seemed to answer the original query properly.
Okay, some websites I've seen have a normal import line in their *HTML* i.e. <style type="text/css" media="all">@import url('/css/foo.css');</style>
foo.css would then just contain one line... i.e.:
@import url('/css/3rdoct04.css');
At the moment I just use the first method but I would like to use the above method of having the import in the HTML to foo.css and then just altering foo.css to the actual file that contains the CSS.
It's much easier for me to edit just foo.css if our CSS changes filename (as it is generated by dates) and saved as something like 3oct04.css than to go through each HTML file and edit the import in the HTML itself.
Hope this is a bit clearer.
I just tested it - and it's working fine on Opera 7.x, IE 6.01,5.5, 5.01, Firefox 0.8+, Safari 1.2 and more.
Regards,That doesn't mean much actually...
You should use the link method on the html pages then the import method on the stylesheet. Then you could even stick in an alternative stylesheet on foo.css for old browsersI don’t see anything wrong with using that method, but how often does one’s CSS filename change…? Why would it change? I, personally, use PHP to include my header onto each page, so if the filename changed I would just have to edit one file anyways (the header).Well his CSS files are based on the date for some reason and he probably doesn't use includes since he wants to set it using a file.Originally posted by IncaWarrior
Well his CSS files are based on the date for some reason and he probably doesn't use includes since he wants to set it using a file.
Ahh, all right. It’s actually a nifty way of being able to change the location/filename of the CSS file without having to go through all your pages and update the HTML.That little level of indirection can be VERY handy from a configuration management standpoint. You can switch to a new style sheet and roll back very quickly if there are problems.
I've seen a few other websites which actually do this, but I wasn't sure whether it's a) "OK", b) whether some browsers wouldn't support it.
Basically, in the HTML itself within the head they have:
<style type="text/css" media="all">@import url('/css/foo.css');</style>
Then, /css/foo.css just contains one line:
@import url('/css/3rdoct04.css');
Is this generally a bad idea?
I'd really like to use this, as it's much easier for me to just edit "foo.css" instead of the HTML itself.
Thanks. Yeah, that's one way, you can also use:
<link rel="stylesheet" type="text/css" href=http://www.webdeveloper.com/forum/archive/index.php/"foo.css" />
but you don't need to import it again in foo.css, you can just put all the CSS stuff there.Hi, thanks for your reply.
Yes, I'm aware of this.
If you re-read my post you'll see why I want to do it that way...It's a good idea to use the LINK tag for importing CSS, however NS4 understands it, to an extent, and usually doesn't look too great. So, it's probably best to use the LINK tag to an import.css file, which imports the main stylesheet file. If you use single-quotes in your import statement, I believe IE5/Mac won't get the stylesheet, either.Opera seems to have a problem when importing styles like so: @import "styles.css";. However, if I use the LINK element to reference a stylesheet, and have only one line in the stylesheet, the import line, then Opera gets it just fine. I don't see why you would want to change the style sheet filename thoughTeach - @import is used in place of <link> in order to hide the stylesheet from earlier browsers which poorly support CSS.Hiya.
Thanks for your replies.
Let me explain my original query a bit more clearly - I don't think I said it very clearly as no one has seemed to answer the original query properly.
Okay, some websites I've seen have a normal import line in their *HTML* i.e. <style type="text/css" media="all">@import url('/css/foo.css');</style>
foo.css would then just contain one line... i.e.:
@import url('/css/3rdoct04.css');
At the moment I just use the first method but I would like to use the above method of having the import in the HTML to foo.css and then just altering foo.css to the actual file that contains the CSS.
It's much easier for me to edit just foo.css if our CSS changes filename (as it is generated by dates) and saved as something like 3oct04.css than to go through each HTML file and edit the import in the HTML itself.
Hope this is a bit clearer.
I just tested it - and it's working fine on Opera 7.x, IE 6.01,5.5, 5.01, Firefox 0.8+, Safari 1.2 and more.
Regards,That doesn't mean much actually...
You should use the link method on the html pages then the import method on the stylesheet. Then you could even stick in an alternative stylesheet on foo.css for old browsersI don’t see anything wrong with using that method, but how often does one’s CSS filename change…? Why would it change? I, personally, use PHP to include my header onto each page, so if the filename changed I would just have to edit one file anyways (the header).Well his CSS files are based on the date for some reason and he probably doesn't use includes since he wants to set it using a file.Originally posted by IncaWarrior
Well his CSS files are based on the date for some reason and he probably doesn't use includes since he wants to set it using a file.
Ahh, all right. It’s actually a nifty way of being able to change the location/filename of the CSS file without having to go through all your pages and update the HTML.That little level of indirection can be VERY handy from a configuration management standpoint. You can switch to a new style sheet and roll back very quickly if there are problems.