What is ViewEncapsulation?

Angular components and templates · Freshers and experienced

Model answer

It controls how a component's styles apply. The default, Emulated, makes styles apply only to that component's template by adding special attributes, so styles do not leak out and global styles still apply in. None makes the styles global. ShadowDom uses the browser's native shadow DOM for real isolation.

Most apps keep Emulated. To style a child component from outside, prefer inputs or CSS variables over breaking encapsulation.

Learn this topic

Angular Tutorial: Beginner to Advanced .

Sign in to add your own answer.

More questions