How to deal with css files only for specific pages.


I have found a html template where I some pages need specific css files and of course there are some common css files.

How can I best deal with it ?


You have the option of creating a specific manifest file for a particular page (or area of the site). This can be a good idea.

You would then need to use a different layout for that page, pointing to the different manifest file.

Usually, what I do is use the same manifest file for the whole site and scope the CSS itself to certain pages (instead of using different manifest files)

In particular, I am a fan of making the tag in my layout look like this:

Then, in my CSS, I scope CSS specific to that page like so:


(this would apply styles only to the home controller’s index action, for example)

If you have two completely separate sections of the website, and the sections do not share the same layout file, then maybe making different manifest files is the way to go.