You sort of answered your own question in the question. The ideal way to do this is with an <iframe>
.
If an <iframe>
is not possible then you can manually ‘scope’ your CSS by prefixing all rules in your ‘frame’ with a certain ID and overriding your default styles:
.style1 { ... }
.style2 { ... }
#widget .style1 { ... }
#widget .style2 { ... }
Coming up in HTML5 you can actually scope CSS within a page. The following will only apply the styles to the inner <div>
.
<div>
<style scoped>
div { color: red; }
</style>
<div>RED</div>
</div>
This isn’t widely supported yet however.
2
solved How to make a page within a page? [closed]