Linked Questions

223 votes
14 answers
191k views

Angular 2 - innerHTML styling

I am getting chunks of HTML codes from HTTP calls. I put the HTML blocks in a variable and insert it on my page with [innerHTML] but I can not style the inserted HTML block. Does anyone have any ...
Jakob Svenningsson's user avatar
354 votes
1 answer
353k views

How to render string with html tags in Angular 4+? [duplicate]

In my angular 4 app, I have a string like comment: string; comment = "<p><em><strong>abc</strong></em></p>"; When I serve this text in my html, like {{comment}} ...
Shams Nahid's user avatar
  • 6,569
91 votes
3 answers
87k views

Angular2 innerHtml binding remove style attribute [duplicate]

My problem, that when I use innererHtml binding - angular2 remove all styles attributes. It's important for me, bacause in my task - html is generated on server-side with all styles. Example: @...
SamProf's user avatar
  • 1,086
37 votes
2 answers
115k views

CSS !important not working

I have the following code and for some reason the !important qualifier isn't working. <div style="font-family : calibri; font-size: 20pt !important;"> <ul> <li> <...
Jim's user avatar
  • 3,705
5 votes
1 answer
4k views

How to render a raw HTML on Angular

I've tried to render a raw HTML using innerHTML, as bellow: <span *ngIf="displacyHTML " [innerHTML]="displacyHTML"></span> This HTML has style in line, but it does not work in that way. ...
ArthurS's user avatar
  • 177
0 votes
1 answer
4k views

Angular 2 Adding html dynamically to DOM, style not working [duplicate]

Hello I am trying to add html from a file that is returned from the api, this is working. what I am needing help with is when I add an inline style it doesn't work, but if I create a class in the ...
3xGuy's user avatar
  • 2,509
0 votes
3 answers
4k views

Angular [innerHtml]: how to render additional elements inside an element with [innerHtml] directive

An element with the [innerHtml] directive just seems to add the declared html string inside that element, and nothing more; through this stackblitz, i was trying to add something inside such an ...
vzR's user avatar
  • 1,547
1 vote
4 answers
2k views

React Js - Styling innerHTML on component - Not working - Parent styling is overriding child styling

I have two react components. List container List The list needs to be inside the list container. Like so: <Container innerhtml={<List></List>} ></Container> The content of ...
Random Stuff's user avatar
0 votes
1 answer
681 views

Angular - InnerHtml with styles

I've this... const htmlVar = "<html> <div style="display:flex"> <div> <h1>Hello World</h1> </div> </div> "; and on my html I've this.. <div [innerHtml]...
Marco Jr's user avatar
  • 6,848
-2 votes
1 answer
781 views

Why can't I style my first word within my Angular ngFor loop?

I'm currently trying to style the first word of a string inside my Angular ngFor loop. Somehow the class get's applied but not the style inside my CSS file. Also inline styling don't works - why? This ...
Mr. Jo's user avatar
  • 5,301
0 votes
0 answers
320 views

Change innerHTML CSS style of iframes and images

I have an Angular 6 app and I'm getting a blog entry from a HTTP call and I set one of the variables which is the content to the innerHTML of a span resulting in the blog content being displayed. It's ...
Carlos Torrecillas's user avatar
0 votes
1 answer
154 views

Stop right scroll image that is shown dynamically

I'm creating an application to create blog posts and show them. The content of blog, along with the image data is stored as a string as HTML content. Upon retrieval in my Angular app, I'm doing: <...
Prachi Sharma's user avatar
0 votes
1 answer
105 views

innerHTML can't catch class from .scss in the component [closed]

The code is in Angular 9. Display the default paragraph. Can't catch class from .scss in the component. .HTML: <div [innerHTML]="htmlCode"></div> .TS: htmlCode: string = "&...
Yugi Oh's user avatar
  • 63