Explain how CSS Isolation works in Blazor. What does the ::deep combinator do?

Last updated 5 July 2026

  • A .razor.css file next to a component scopes its styles: Blazor stamps a unique attribute (e.g. b-abc123) on the component's elements and rewrites selectors to match it.

  • All scoped rules are bundled into one {Project}.styles.css file. Styles apply only to the component's own markup, not to child components.

  • The ::deep combinator lets a scoped rule reach descendants (e.g. ChildContent or child component markup) by applying the scope attribute to the ancestor only.

  • https://learn.microsoft.com/en-us/aspnet/core/blazor/components/css-isolation?view=aspnetcore-10.0
  • https://docs.devexpress.com/Blazor/404361/styling-and-themes/css-isolation
  • https://daily.dev/posts/blazor-s-css-isolation-deep-issue-and-solution-lzbjr6afr
  • https://khalidabuhakmeh.com/posts/blazors-css-isolation-deep-issue-and-solution/
  • https://jonathancrozier.com/blog/styling-blazor-child-components-with-css-isolation-what-you-really-need-to-know
  • https://code-maze.com/css-isolation-in-blazor-applications/
All Blazor interview questions