One CSS file for multiple pages? How do I style each individual page differently?

So, I’ve read its best practice to use one CSS file per website.

while I want most of the CSS for each page (the general layout) I want to change some styling for each individual page for obvious reasons.

How do you do this if it’s best practice to only use one CSS file? Every page would look exactly the same.

still trying to figure out how people deal with this if anyone knows.

so I am going to guess without reading your sources, that the reason they suggest one css file per website is because they want each page to look the same.
(This is part of good design. Think of a website like CNN for eg. You can click on different parts of the site but it is completely consistent in how it is presented on each section)

But you can ignore this! Add as many files as you like :sweat_smile:

Well, I do one every page to have the same general layout.

However I had a problem, when I remove a div that is using innerHTML in my javascript file from an html file I don’t want it in I get an error.

I’m using a “container” and displaying all of my "products’ with a for loop in my javascript. I don’t want that to happen on my other page but it won’t let me delete it.

hmm, sounds like a new problem. You can open a new topic and give people access to your code (if it is in a live place like codepen) so they can examine in detail.

As for the “have the same general layout” comment. Remember that in software development, we do not like to repeat ourselves. We are lazy.
If you have a section of css that is being copied and pasted across different files, then you need to redesign. (perhaps put the repeatable section by itself in a css, and link that part alone, then the specific css files after it depending on the specific page)

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.