Should I use one or more css files?

I’m on the web development track and thinking about creating my first project, but I have a question of what is best, should I have a css file for all my site pages or a css file for each page? How is the best way to organize it?

I learned on youtube that it is best to have a reset css in a file and use another file with my main css, but I think I could separate the main css file in other files so it is more readable.

Any thoughts about it?

Hello @lassekoivisto.

Yes. This is a very good idea, as it allows you to reset any mistakes you make and so you can tell what the basis of the site should be like.

This is also a good idea, as it make the code more readable, and is therefore better than inline styling.

Should you use multiple files?
If you are purely concerned about making it easier for yourself, then I would say yes, however, more files increase the loading time, and means that you have to repeat a lot of rules, for example, if you wanted all headers to be blue, you would have to specify that in each file. One thing you could do is to have a main.css file that contains most of the CSS. Then, if any pages warrant specific styling, that is different to the overall styles, then you could do a page for that one. But it is up to you how you organise your files.
I hope this helps!

2 Likes