1 CSS file, 2 html files, best practice for styling same element differently

I’ve read that if you have a simple site with just a few .html files you should try to use one .css file. I also read you shouldn’t use IDs for CSS styling. Curious the best practice if, for example,I want the h1 on my index.html to be blue but the h1 on form.html to be red what the best practice is if I shouldn’t just add IDs in the h1’s.

Correct, it’s better to use classes than ids for css. You can simply declare different classnames to give styles to different h1s in each file.

Here is an article on why.

1 Like

Awesome, thanks! Wasn’t sure if I should use a class on an element that will only appear once on an html page but that sure works. And really glad you shared that dev.to site. Can’t believe Google and I haven’t come across it.