Jump to content
Larry Ullman's Book Forums
Sign in to follow this  
fredtbx

Adapting A New Site From Ex1 In The Book

Recommended Posts

Hi,

 

I'm adapting a new site from Ex1, but have a question.  What is the best way to include css on a script that includes the header.html file, but wants to use additional css on the rendered page.  Seems that if I want to use different css on each script it would clutter up the header.html, could have 100 different css files included in header.html but just one at a time being used.

 

TIA 

Share this post


Link to post
Share on other sites

Interesting question! Generally speaking, the trend is really to use a couple (1-3) CSS sheets across every page with the expectation that your visitor will visit multiple pages and the initial extra download is covered by the caching benefit. (To be clear, those 1-3 sheets would define all the CSS needed by every page even if every page doesn't need every thing.)

 

Moreover, the idea that you might need more than, say, 5 different style sheets for a site sounds problematic, unless the site has multiple distinct sections.

 

All that being said, a solution here would be to define a variable on a page that identifies an additional CSS file that's required. Then your header.html would check for that variable and if it has a value, include that CSS file, too.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...