0

I have an html element in my angular app that looks like

<p class="headline" [innerHTML]="content.headline"></p>

And content.headline is "<sup>$</sup>425MM". I want to apply specific styling to the sup element.

In my css file, I have tried:

.headline sup {
    color: red !important;
}

sup {
    color: red !important;
}

.headline > sup {
    color: red !important;
}

p sup {
    color: red !important;
}

p > sup {
    color: red !important;
}

None of these work. What am I doing wrong? How can I achieve this styling?

4
  • This looks wrong - <p class="headline" [innerHTML]="content.headline"></p> should that not be <p class="headline"> [innerHTML]="content.headline"</p>? Commented Sep 3, 2021 at 17:34
  • see this answer for ref stackoverflow.com/questions/41979458/… Commented Sep 3, 2021 at 17:38
  • Why use innerHTML in the first place? Commented Sep 3, 2021 at 17:42
  • 1
    Might be useful along with this. Commented Sep 3, 2021 at 17:46

1 Answer 1

0

Based on this so post shared by Nicholas K, I got an answer

::ng-deep sup {
    color: red !important;
}
Sign up to request clarification or add additional context in comments.

1 Comment

Except it is deprecated, as stated in Angular docs : angular.io/guide/component-styles#deprecated-deep--and-ng-deep. You could import global css or use ViewEncapsulation.None.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.