Home
← All questions

Shadow DOM and Web Components | Web Fundamentals

HardPremiumWeb Fundamentals

Asked at Google · Salesforce · Adobe

Web Fundamentals interview practice: Encapsulate styles and markup with Shadow DOM — design systems and micro-frontend topic.

Answer

Web Components are browser-native reusable elements:

  • Custom Elements — define new HTML tags
  • Shadow DOM — encapsulated DOM + scoped CSS (not leaked to/from light DOM)
  • HTML Templates — inert <template> cloned into shadow root

Benefits: style isolation, composable widgets, framework-agnostic design systems (e.g. Shoelace, Lit).

Trade-offs: harder global theming, SEO/testing complexity, event retargeting (events appear from host element).

Premium question

Unlock the full model answer with Mentoxis Premium.

Unlock with Premium