Search⌘ K

CSS Isolation

Explore how to implement CSS isolation in Blazor WebAssembly apps to control component-specific styling. Learn to create isolated CSS files, override global styles, and apply styles to child components using the ::deep combinator. This lesson helps you avoid styling conflicts and build customizable, modular UI components.

The location of the cascading style sheets (CSS) used to style our Blazor WebAssembly apps is usually the wwwroot folder. Usually, the styles defined in those CSS files are applied to all of the components in the web app. However, there are times when we want more control over the styles that are applied to a particular component. To achieve that, we use CSS isolation. With CSS isolation, the styles in the designated CSS file will override the global styles.

Enabling CSS isolation

In order to add a CSS file that ...