SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Zealot
    Join Date
    Aug 2004
    Location
    CA
    Posts
    141
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question External stylesheets

    Do you think it's better to set up your CSS styles in an external stylesheet? It would mean another HTTP request, but the search engines might see your page with a higher content-to-code ratio.

    - Grant

  2. #2
    He's No Good To Me Dead silver trophybronze trophy stymiee's Avatar
    Join Date
    Feb 2003
    Location
    Slave I
    Posts
    23,449
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Do it because:

    1) It helps to keep your code clean which benefits your brain

    2) It allows the browser to cache the file so it doesn't have to retrieve it with every request. That makes your server and bandwidth happy.

    The effect that would have on SEO will be extremely little to none and shouldn't even be considered.

  3. #3
    SitePoint Wizard bronze trophy bluedreamer's Avatar
    Join Date
    Jul 2005
    Location
    Middle England
    Posts
    3,265
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    External stylesheets are 'standard practice' these days

  4. #4
    SitePoint Member QRiO's Avatar
    Join Date
    Jul 2006
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    and what about if we put external stylesheet on page at request time using some thing like

    Code:
    <style>
    <?php include "stylesheet.css"; ?>
    </style>
    any advantage or disadvantage ?

  5. #5
    Chillin like a Villain DaStuff's Avatar
    Join Date
    Jul 2003
    Location
    Huntington Beach
    Posts
    649
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't see any benefit over:
    <link href="http://www.website.com/css/standard.css" rel="stylesheet" type="text/css" />

    In both situations you can easily update and change the css for the site. The best thing about external (imo) is the fact that it cache's the file, saving you a lot of download time down the road (making your site more friendly to those slower dialup speeds)
    • Follow the dancing banana

  6. #6
    SitePoint Zealot
    Join Date
    Aug 2004
    Location
    CA
    Posts
    141
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is it alright to have most of the style definitions in an external stylesheet, but also have a few definitions in the head tag? This is necessary because I have a few variables defined in my stylesheet. Those variables can only be parsed on the actual page.

  7. #7
    SitePoint Guru MikeBigg's Avatar
    Join Date
    Jun 2004
    Location
    Reading, UK
    Posts
    970
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by QRiO
    Code:
    <style>
    <?php include "stylesheet.css"; ?>
    </style>
    This will just put the style in the html that is served to the browser. ie this isn't external linking as seen by the browser.

    Do a view|source on the page to see how it includes it.

    Mike

  8. #8
    SitePoint Addict
    Join Date
    May 2006
    Posts
    399
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I would always (I think) use define my styles in an external style sheet. If you use DW8 is has the useful feature of exporting styles externally which is vewry handy in the early development phase.

  9. #9
    SitePoint Member
    Join Date
    May 2006
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    One external style sheet allows you to make site-wide changes in a single document. If you have a large site, this is a gigantic time saver.


Bookmarks

Posting Permissions

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