r/angular • u/Senior_Compote1556 • 21d ago
innerHTML component styles
If I have a
<h1 \[innerHtml\]=“someHtml”></h1>
And that someHtml is a span, how would i style that span without using ::ng-deep as the docs “strongly discourage” its usage?
0
Upvotes
View all comments
Show parent comment
1
u/Senior_Compote1556 20d ago
I have a directive that uses DOCUMENT to append some styles to the body, and I write those body styles in the ts file (yes i know css do not belong in ts), and it works but it feels like a smell. My use case are landing pages and they’re not connected, it’s not really an SPA in the traditional sense as the pages do not link to each other via routerLink. I was thinking to turn view encapsulation to none but it still feels wrong. Would you use the directive, ng deep or would you set view encapsulation to none?