0
0
Angularframework~5 mins

Component styles and encapsulation in Angular - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is style encapsulation in Angular components?
Style encapsulation means Angular keeps component styles separate so they only affect that component, preventing styles from leaking out or being affected by global styles.
Click to reveal answer
intermediate
Name the three encapsulation modes Angular supports.
Angular supports: 1) Emulated - styles scoped to component using attributes, 2) None - styles are global, 3) ShadowDom - uses native browser shadow DOM for true encapsulation.
Click to reveal answer
intermediate
How does Angular's Emulated encapsulation work?
Angular adds unique attributes to component elements and styles, so styles apply only to that component's elements, simulating style isolation without native shadow DOM.
Click to reveal answer
beginner
What happens if you set encapsulation to ViewEncapsulation.None?
Component styles become global and can affect any element in the app, losing style isolation.
Click to reveal answer
advanced
Why might you choose ShadowDom encapsulation in Angular?
ShadowDom uses the browser's native shadow DOM, providing true style and DOM encapsulation, which is useful for web components or when strict isolation is needed.
Click to reveal answer
Which Angular encapsulation mode scopes styles using unique attributes but does not use native shadow DOM?
AGlobal
BEmulated
CShadowDom
DNone
What is the effect of setting encapsulation to ViewEncapsulation.None?
AStyles are scoped only to the component
BStyles are ignored
CStyles become global and affect the whole app
DStyles use native shadow DOM
Which encapsulation mode uses the browser's native shadow DOM?
AScoped
BNone
CEmulated
DShadowDom
Why is style encapsulation important in Angular components?
ATo prevent styles from leaking and affecting other parts
BTo make styles global
CTo disable CSS
DTo speed up rendering
If you want to create a reusable web component with strict style isolation, which Angular encapsulation should you use?
AShadowDom
BEmulated
CNone
DGlobal
Explain the differences between Emulated, None, and ShadowDom encapsulation modes in Angular.
Think about how styles are applied and isolated in each mode.
You got /3 concepts.
    Describe why style encapsulation matters when building Angular components and what problems it solves.
    Consider what happens if styles leak between components.
    You got /3 concepts.