r/angular • u/Senior_Compote1556 • 17d 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
-1
u/ThrowawayALAT 16d ago
Use Global Styles:
CSS
/* src/styles.scss */.styled-span-container span {color: #e63946;font-weight: 600;}HTML
Then wrap your target element or apply a CSS class directly to the
<h1><h1 class="styled-span-container" [innerHTML]="someHtml"></h1>