PDA

View Full Version : CSS External or Not?!


djshongo
04-06-2009, 02:23 PM
Hi,

Im kind of new tho the CSS scene, im using DW8, and im kinda confused with the whole style sheet set-up.
I hear ppl talking about External and Internal ones, and im not sure of the diff..

Basically, i have a website, made from a template, with 10 pages. The only thing that changes is the main content area, and sumtimes the page packground. So 2 editable regions.

Using DW8 i have about 4 style sheets set up, (using the wizard after creating DIVS), so im guessing they are internal right?!

What i want to know, is can i just have ONE style sheet with ALL the rules in it, like for background color, font, tables, pics etc...
Or is it better to break these style sheets up internally like DW8 has did for me this far?

..sorry if i dont make complete sense lol

thanks in advance for the help :)

J

Corrosive
04-06-2009, 02:28 PM
Hi,

Im kind of new tho the CSS scene, im using DW8, and im kinda confused with the whole style sheet set-up.
I hear ppl talking about External and Internal ones, and im not sure of the diff..

Basically, i have a website, made from a template, with 10 pages. The only thing that changes is the main content area, and sumtimes the page packground. So 2 editable regions.

Using DW8 i have about 4 style sheets set up, (using the wizard after creating DIVS), so im guessing they are internal right?!

What i want to know, is can i just have ONE style sheet with ALL the rules in it, like for background color, font, tables, pics etc...
Or is it better to break these style sheets up internally like DW8 has did for me this far?

..sorry if i dont make complete sense lol

thanks in advance for the help :)

J

I try and use just one stylesheet. Internal styles are in between your <head> tags in your html page. External are in a separate file with a .css extension and they are referenced in the <head> tags.

djshongo
04-06-2009, 02:43 PM
Yea all the ones i have are .css files and are seperate from all my other files.

So could i not just copy all of the code into ONE style sheet and name it accordingly?

Corrosive
04-06-2009, 03:13 PM
Yes, that's what I'd do.

djshongo
04-06-2009, 04:02 PM
cool.

thanks!!

chode
04-07-2009, 09:47 AM
Most of your site should be controlled using an external style sheet. But if there is something specific you want to change on only one of your pages and not have it affect the rest of your site then just apply an internal css style to that page only.
Im by no means an expert so if Im wrong then hopefully someone will correct me!

Chode

djshongo
04-07-2009, 01:04 PM
Thanks for the advice, think i'll try it out 2day and see how it goes :)

I just like the idea of having ONE style sheet to control my info, the only things i will change anyway are font sizes, colours, picture borders and alignment, so im guessing thhe one external style sheet would do me?

:)

Corrosive
04-07-2009, 01:43 PM
Thanks for the advice, think i'll try it out 2day and see how it goes :)

I just like the idea of having ONE style sheet to control my info, the only things i will change anyway are font sizes, colours, picture borders and alignment, so im guessing thhe one external style sheet would do me?

:)

Yes, one sheet is fine. As Chode says you can mix it up if you want inline/external. TBH if I even want a style specific to one page I'll still define it in my one stylesheet. Nothing worse than finding you need it somewhere else later and not having it linked! The beauty of CSS is that, to a greater extent, YOU make the rules :)

chode
04-07-2009, 01:45 PM
Yeah it should. Hard to say. Every project is different. Just remember if you start a new page and something isn't doing something you think it should but just ask yourself if the external style sheet could be having an effect on it. Got me a few times on my first few sites.

domedia
04-07-2009, 04:09 PM
But if there is something specific you want to change on only one of your pages and not have it affect the rest of your site then just apply an internal css style to that page only.
Im by no means an expert so if Im wrong then hopefully someone will correct me!
ok, here is the correction :)
You should still use an external stylesheet , even if you have styles that are only for one page.
Be smart about how you use selectors and apply the style to only that page.
Benefits:
You're still separating style and content, and you can now easily apply this style to other pages later.

chode
04-07-2009, 11:00 PM
Hey Domedia cheers for the reply!

Sorry just realised I wasn't very clear reading it back myself. I did mean still use the external style sheet for the page you want to change something on. But you can add an internal style as well to individual pages (as well as the external). Is that what you are saying?

sorry, its early and I might have just confused you more :(

Ricky55
04-08-2009, 01:05 AM
No Dom is right, one external style sheet should be all you need for most average sites, if you are doing something large then you may need to split this down to several external style sheets just to keep some order but not so it doesn't effect other pages.

You control which elements the style affects by using selectors. You should never have to create a new style sheet just so it doesn't affect something on a particular page.

One thing I commonly do if you want to build more intelligence into your CSS is to give the body tag an ID. I commonly use this for down states for my menus for instance.

So then I can say when the home has an ID of home make the home button have a down state, when the body tag has an ID of contactUs make this have the down state and so on.

I can remember the first site I did in CSS and I had a style sheet for every page, the only difference being the style for the menu.

So one external sheet is the way to go. I sometimes use internal style if I'm doing like a coming soon page or something when it doesn't justify creating an external sheet but if I'm doing a full site the first thing I do is create an external sheet and link it.

The real power of external sheets comes when you need to make changes and you want them to populate site wide.