HTML & CSS · Middle · Question 37 of 75
How do CSS Modules solve class-name collisions?
- 1They forbid using identical class names across the project at build time
- ✓Correct answer: They generate unique class names, making styles local to the file
- 3They wrap every component in a Shadow DOM, isolating its styles
Explanation
The .title class from Card.module.css becomes something like Card_title__x7a2b, and the component imports a mapping object. Collisions disappear without naming conventions. Global styles use :global. Shadow DOM is a Web Components mechanism; CSS Modules don't use it.