Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The * selector in react/next.js

I am currently working on my first website in react. In my main.module.css I have

* {
    padding: 0;
    margin: 0;
    box-sizing: border-box;
}

Just typical css styling reset. But React returns the error:

Syntax error: Selector "*" is not pure (pure selectors must contain at least one local class or id)

Do you have any solution for that? I want to keep this styling reset instead of adding those three lines to every element i have.

like image 382
Foxnacity Avatar asked Nov 15 '25 13:11

Foxnacity


2 Answers

You should not have styling reset in module.css file. Move this css reset to normal css file like index.css file.

Styling file with .module.css extensions are used to define the styling you can say local to a components. It means that if you import a module.css file in two different components, both components will have same styles with different class names. This one prevents overriding of styles.

like image 116
Mohit kumar Avatar answered Nov 18 '25 21:11

Mohit kumar


That would go into global styles, which can be done by simply adding:

require('./name-of-your-global-style.css');
like image 37
Rameez Avatar answered Nov 18 '25 19:11

Rameez



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!