Jump to content

css etiquette


Glom

Recommended Posts

My website uses a standard template for all pages except the front page, which has its own layout. Currently, all styles data, including css layout, relating to this page is put in a internal stylesheet since this page is unique.Here's the question:Is this proper etiquette for stylesheets, or is it proper to put the it into an external stylesheet even though only one page is using this data?

Link to comment
Share on other sites

It's best to put the styling in both sections I would say. If your front page shares common things with the rest of the site, theese things will be gathered from the external stylesheets. Only per page data should be kept in the head section.Infact, you could use multiple stylesheets for the whole of your site if you think about it. For example, put the things which the front page shares with the rest of the site in one stylesheet and the things that all other pages use in their own stylesheet. The second stylesheet will be loaded when the user goes into the site, thus reducing download time for the front page.

Link to comment
Share on other sites

User preference i would say. If i was you and only one page used these styles then i would put them straight into the head section. css is quite flexible, you can achieve the same thing different ways :)

Link to comment
Share on other sites

It's best to put the styling in both sections I would say. If your front page shares common things with the rest of the site, theese things will be gathered from the external stylesheets. Only per page data should be kept in the head section.

I totally agree it is a total waste to repeat any of the styles in both the head of the first page and your main CSS file.
Link to comment
Share on other sites

The layout information for the front page is different so I currently have it in the head of the page. I was thinking that maybe it would be better to put it into an external css because the html itself would be smaller and the css data could be cached shortening future download times. Does that logic make sense or not?On a similar note, I have a glossary page, which naturally uses the dd and dt tags. That is the only page I use them. Would it then be better to simply put the style information for those tags in the head section of that particular page?

Link to comment
Share on other sites

The layout information for the front page is different so I currently have it in the head of the page.  I was thinking that maybe it would be better to put it into an external css because the html itself would be smaller and the css data could be cached shortening future download times.  Does that logic make sense or not?On a similar note, I have a glossary page, which naturally uses the dd and dt tags.  That is the only page I use them.  Would it then be better to simply put the style information for those tags in the head section of that particular page?

To assist my future revisions, I put code that is used by only that page on that page only. I don't like repeated unnecessary repetitions.
Link to comment
Share on other sites

why not put all the css in the same file if you only have 2 layout styles. Just add the styles to the .css file and make sure theres no conflicts, atleasts that what i do

Because this means the user would have to wait for the second layout to download while (s)he's visiting a page which only uses the first layout. This means longer downloadings.If certain CSS properties are used only on one page, it's perfectly fine to have them in the XHTML. Scince the XHTML itself is also cached, this means it doesn't matter if a per page style is in external file or in the XHTML.
Link to comment
Share on other sites

It is also said that for high-traffic pages embedding your CSS to the page is a good idea anyways. Not sure why really, I suppose it is just less work not having to import the css file.But I do have all my styles in a css file and then any styles that are for one page only in the head of that one page. (Unless your talking a whole layout for a page then an extra CSS file is more approriate I think)

Link to comment
Share on other sites

I try to have all styles on an external sheet, I have very few styles coded into the head section of my pages. That makes any global changes that much easier in the future. Even if at this particular time I don't forsee any changes being made. The download time for a stylesheet is not that much, and more than likely not noticeable to the user. You just don't know what will happen a year or two from now when you may very well want to change the global styles of your site to reflect your index page.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...