Adomas Kondrotas
Adomas Kondrotas

Reputation: 49

Use CSS for certain block (scoped CSS)

I have application where user can paste their html code, when ever I paste html with style tag those CSS rules are applied to my application too.

Those CSS rules should be applied only to pasted code.

Found this:

http://www.w3schools.com/tags/att_style_scoped.asp

But it only works with firefox, would be perfect solution for this problem.

Now I'm thinking about parsing pasted CSS rules and applying them to html as inline css rules.

Is there any better solution?

Upvotes: 0

Views: 65

Answers (1)

Justinas
Justinas

Reputation: 43507

Use iFrame to provide safe way of showing user supplied HTML code. That way even when user tries to overwrite your site to look like bank account he still have no access to outer-iFrame content.

Upvotes: 1

Related Questions