loading...

How to add global CSS in the public html file in React - Create React app (CRA)?

alidhuniya profile image Ali Hussain Dhuniya ・1 min read


The short answer is CRA(create react app) doesn't know about those files unless you import them in js. so import it in index.js file. For more clarity, watch the full video

Then why the title says how to add in public HTML file? It's because all the things wrapped inside one div root id in public HTML file that's how most people think at first when it comes to applying global or base styles in web app. And index.js file target div block with id "root" so index.js is the way to import your global css.

This video will show you how to add global css or base styles which are required for your whole app

Here I'm referring global or base styles as the combination of normalization, resets, variables, placeholders, mixins, function. At the moment vanilla CSS doesn't support placeholders, mixins, functions which are sass features.

This is an ongoing project with contentful CMS.check out github code here: singerProfile

google solution link

Read more of my articles on dev.to here: https://dev.to/alidhuniya

Posted on by:

alidhuniya profile

Ali Hussain Dhuniya

@alidhuniya

Learning Frontend Development

Discussion

markdown guide