tags:

views:

45

answers:

2

Should i keep CSS of home page and landing pages in separate CSS file of big sites. ?

If i make site with a 7-8 different templates where 1 templates of home pages 1 is for inner content pages and other template for different type of landing pages.

and different style needed for same HTML elements in website ,

For example :

for inner pages H2 has different style but for landing pages H2 is different in color, font -size, line height, top bottom margin

How i should manage all this ? any tips to make good,easily manageable, scan-able CSS.

Thanks in advance.

A: 

It depends on how much of the CSS is reusable and how much is specific.

David Dorward
typography of home and landing pages is different and for other pages it's same. header and footer, width of container ae same across the site.
metal-gear-solid
And the typography consists of what? 5% of the CSS? 97% of the CSS?
David Dorward
typography of site is consistent in 95% cases other than 5% which is on home and landing pages. The problem is in inner pages I use h1 h2 as needed in content but on home and landing pages which has boxes for different purposes in that boxes I also use h2 , h3 etc for content boxe's heading where i need different color, font -size, line height, top bottom margin of heading and other typographic elements
metal-gear-solid
and css of site will be handled by other people after finished my work if any changes comes in future in design from client side.
metal-gear-solid
@metal-gear-solid - you should never just overwrite h2 in such cases, make it also class dependent, something like => h2.homepage / h2.subpage
ntziolis
@ntziolis - will class properties override on HTML selector's properties?
metal-gear-solid
http://www.w3.org/TR/CSS21/cascade.html#specificity
David Dorward
A: 

what about using different <body id="home_page"> <body id="download_page"> and so on!?

or something like wrapper or content as usual instead of using body!

so you have:

body { padding:0; margin: 0; text-align:center; } /*applied to all*/    
h2 { font: normal normal 14px sans-serif } /*applied to all*/    
#home_page h2 { color: #333 }   /* home page only */ 
#download_page h2 { color: #666 } /* download page only */ 

just an example but you got the idea!

UPDATE

if you are using CMS, i don't know if is a common cms or one created by you, and also i don't know if you are free to edit it as you want in a custom way, or need to be a plug and play for client!

Assuming you are rendering all the pages content with php, then you can

1 - check for what page the user is viewing and switch style! not very elegant although!

2 - your cms may have OR if of your creation should have some option for theme creation like:

define( DEFAULT_STYLE , true ); //or false this would make my very fisrt responce real!

3 - render the CSS from backend header("Content-type: text/css"); based on what is the user request!

aSeptik
the problem of this method is we work on CMS which already adds ID to `<body id="download_page">` but the problem can arise for other pages bcoz this function is dynamic , for example if client will change "download page" to "download section" then body will be changed to `<body id="download_section">` and css will not work
metal-gear-solid