Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

external vs internal css 2

Status
Not open for further replies.

TFfan

Programmer
Jan 18, 2002
192
CA
Is there a general rule of thumb? Is one preferable to the other in certain situations? Does an external SS load only once per website or with each page refresh/page.

Thanks!
 
personal preference deffinetely comes in on external or internal. The length of the style sheet usually dictates my actions and how the reaction to viewing the code in the page is. eg: messy and hard to read!

on the style sheet being loaded with each refresh. only if you code for a no-cache situation will this happen. otherwise the style sheet is cached thus preventing a multiple lag in loading after the initial view.

____________________________________________________
get the best answer to your questions by asking the best questions "General FAQ" faq333-2924
onpnt2.gif
 
Thanks. I'm just trying to get some method to my coding.

Just to clarify. So if your SS is 50 lines and is internal, the browser would read in those 50 lines with each page load. If an external SS is used, it would only have to read those 50 lines once.

I know this isn't much time saved, but wouldn't that be preferable, especially given the ease of website modification with external SS?
 
the same concept from the external to internal sheet will apply as far as load time goes. The page will be cached just as the .css would be cached. again, unless a no-cache is involved.

The external file will take more resources to load the page just due to the extraction from a outside source when the link is interpruted by the browser. however from my exp. I have never noticed any amount of resource disabilities from a thousand line externally described css to a internal.

____________________________________________________
get the best answer to your questions by asking the best questions "General FAQ" faq333-2924
onpnt2.gif
 
My own personal preference is to use a single external CSS page wherever possible. If I must override a style, I'll do so in the document itself, but I'm loathe to for exactly the very same reasons I never use the <FONT> tag. basically, I follow the model for CSS -- separate document, then header section if I must override the style from the external doc, then specific element if I must override the header styles. That's the way they were designed, near as I can figure out.

This serves me two purposes:
[ol]
[li]I can maintain a single style file better than styles in a hundred different documents. This cannot be overstated.[/li]
[li]Pure throughput -- as long as the browser caches the CSS document (most will), it only downloads it once for the whole site. If I had styles in each page, then I would be making them download redundant things. Heck, if I had to define some wonky style for each page, then I've no business designing a site in the first place![/li]
[/ol]

Cheers,


[monkey] Edward [monkey]

&quot;Cut a hole in the door. Hang a flap. Criminy, why didn't I think of this earlier?!&quot; -- inventor of the cat door
 
I'll cast my vote for external SS too - easier to maintain, even for small sites.

<?legalstuff
The above is my opinion only and should not be construed as the opinion of my employer.
?>
 
Just think of this... is Xmas and you want to change the color of your pages to match the season, or is Halloween, or mothers day.... anything.
I use not only one but several external pages with the same attributes and classes. with different colors and properties for each.

I have a list of external CSS files named like
main.css
main_xmaz.css
main_halloween.css
main_regular.css
main_anything.css

On my pages I have a Link to main.css only.
when a season comes I just rename my main.css to main_old.css and make a copy of one of the other files and rename the copy as main.css.

In less than 5 minutes my whole website has a different face.
Try that using internal CSS definitions and see how long it takes.

bottom line: go with external CSS.


grtfercho çB^]\..
&quot;Imagination is more important than Knowledge&quot; A. Einstein
 
again, this all is preference driven and has no to little technical resource concern on the site. Of course common sense tells us how we should do it.

____________________________________________________
get the best answer to your questions by asking the best questions &quot;General FAQ&quot; faq333-2924
onpnt2.gif
 
To see this in action go to
from the menu select &quot;My DWFaq&quot; >> &quot;My DWfaq's Style&quot; a new window will open select the style and see how the whole website changes in a snap.

can't beat that.;)

grtfercho çB^]\..
&quot;Imagination is more important than Knowledge&quot; A. Einstein
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top