Results 1 to 6 of 6

Thread: Usage of CSS file

  1. #1

    Thread Starter
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Usage of CSS file

    To what extent should an external CSS file be used? If it's possible to specify just about every attribute required on the page in that CSS file, is it advisable?

    And what if the CSS file grows to be too large? How large is considered 'too large', btw?

  2. #2
    Hyperactive Member BramVandenbon's Avatar
    Join Date
    Jan 2002
    Location
    Belgium
    Posts
    502
    As far as I know CSS can only be used for Format and lay-out.

    Not the text itself.

    CSS however is advisible. I always put about everything in my CSS-file. The file can be as big as you want. But keep in mind, the user will have to wait till the file is downloaded when he visits your site. So don't make it like 2 MB

    If you also want to specify your text in an external file I suggest you use (CGI) SSI. It's very easy. (It's also known as SHTML.) But your webserver will have to support it.

    <!--#if expr="${HTTP_USER_AGENT} = /MSIE/" -->
    <!--#include file="file1.txt" -->
    <!--#else -->
    <!--#include file="file2.txt" -->
    <!--#endif -->

    this is a very nice example of SSI. I don't think I have to tell you how it works. The commands speak for themselves.

    If you don't like SSI, you can always try PHP or ASP ... ASP is my favourite. It works fine with Access or SQL server, etc ... (However, it sometimes creates conflicts when using both CSS and ASP-forms in the same file.)

    Enjoy.
    ____________________________________________

    Please rate my messages. Thank you!
    ____________________________________________
    Bram Vandenbon
    http://www.bramvandenbon.com

  3. #3

    Thread Starter
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    That would obviously require CGI support, wouldn't it?

    Code:
    <link rel="stylesheet" type="text/css" href="quack.css">
    Shouldn't this be the 'proper' way?

  4. #4
    Frenzied Member Rick Bull's Avatar
    Join Date
    Apr 2002
    Location
    England
    Posts
    1,444
    Yep that's the proper way. I would definately advise using CSS totally externally, there are a few benifits:

    • If you want to change the layout you only have to change the one CSS file, not the HTML pages
    • Quicker downloads as browsers cache CSS files
    • People with really old browsers will have even quicker downloads as they don't even get it (very few of these about any more anyway, but text-browsers for example would benifit)
    • Makes for better accessibility
    • A lot of the older methods (like font) are either deprecated or removed in newer standards.


    probably a bunch more too Plus you can make media dependant style sheets (e.g. screen, print, teletype, etc), so only the right ones will be downloaded, and you can have your page formatted different for different mediums. My site is totally external CSS by the way.

  5. #5
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032
    There's also an @import way of using an external file.
    Josh
    Get these: Mozilla Opera OpenBSD
    I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.

  6. #6
    Hyperactive Member BramVandenbon's Avatar
    Join Date
    Jan 2002
    Location
    Belgium
    Posts
    502
    yep here's the syntax of the import !

    @import "mystyle.css";
    or
    @import url("mystyle.css");
    or
    @import url(mystyle.css);

    The 'LINK' element references alternative style sheets that the reader can select, while imported style sheets are automatically merged with the rest of the style sheet.

    http://www.w3.org/TR/REC-CSS1
    ____________________________________________

    Please rate my messages. Thank you!
    ____________________________________________
    Bram Vandenbon
    http://www.bramvandenbon.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width