2

We have an single-page web app that displays emails. Some of the emails we're viewing contain style elements that, when loaded into the DOM, affect our entire app. What's the best way to prevent this from happening? I'm currently removing style elements using the HtmlAgilityPack as shown in the post below, but I'm wondering if there's an easier way.

Regex to remove body tag attributes (C#)

Community
  • 1
  • 1
neonbytes
  • 239
  • 2
  • 10

2 Answers2

4

Use iframes. That will put the message into a separate document, and there will be no styling interference.

Pekka
  • 418,526
  • 129
  • 929
  • 1,058
  • almost 6 years on would this be the same case, Could web components be a better choice than iframes these days? – Birdy May 05 '17 at 18:52
0

Since you said html emails, the only way to make the Css work is to give inline css style's. External CSS will never work on html mails.

defau1t
  • 10,373
  • 2
  • 32
  • 45
  • Not really an answer to the question IMO - from what the OP says, there are clearly classes present that distort the rest of the document. – Pekka Jan 06 '12 at 00:55