It is good practice to have a CSS file for each HTML file?

I am recreating a webpage , but it looks like each page is not similar to the other and I was wonder if maybe is better to have a specific CSS file for each HTML file instead of keep writing code in the same CSS file.

Hey @raquetica,

If your web pages are really different from each other, using separate CSS files for each might make it easier to manage. This way, you can customize as much as you need without messing up the styles on other page. This case you’re describing might suit seperate CSS files if the style differs quite a bit from each other.

But, if your site’s pages look pretty similar overal, sticking with one CSS file is probably the way to go. It keeps everything consistent and is less of a hassle to manage. Plus, it’s faster for folks visiting multiple pages since the browser caches the CSS after the first page.

You can also go the approach where you use CSS imports and then @import them into CSS files. Examples of this would be if every page users the same navigation bar and footer, you can just use @import to fetch these rather than copy pasting the same code all the time.

Reference: CSS @import Rule.