Internal or External CSS

liunx

Guest
If you have a layout that is in use only on one HTML document, is it better to set it up in an internal style sheet in the head, or make an external style sheet specifically for that document?

I've got style sheets up the yin yang already, so adding a few more won't matter.It generally won't matter because it's used on a single page UNLESS the sheet is rather large relative to the page size and the page is continuously revisited.It IS a rather large style sheet, and I'm expecting a quite a few visits to this page. (My contact page.)If the page is likely to get multiple visits per user, than you can put it in an external sheet. If it's rather large, you might want to separate it just for ease of maintanancce.What if you get multiple visits, but the internal sheet's really small?I agree with Ray. It'd only make sense to include it on mutliple pages so you could make global changes with ease (and of course, save bandwidth). However, if it's only being used on one page there is no need to make it external.That's the only time you should add internal CSS when it will only affect one or two pages even then it's still better to use external ?especially should you want to change to XHTML.Originally posted by Robert Wellock
...especially should you want to change to XHTML.

I'm already using XHTML 1.0ya it doesn't really matter....I'd go for an external CSS file if two conditions exist:

1) The CSS required is large in file size

2) The single page it formats gets updated frequently.

If you are constantly changing the content and not the design, it's beneficial to keep your CSS separate so that the markup and design don't have to be Download ed each time you update the page.

Otherwise, keep the CSS inside the HTML file. That's one less trip back to the server to retrieve a file. Sometimes the time saved by using an external CSS file is eaten up by the number of times a browser has to make requests to a Web server for additional files.
 
Back
Top