Use targeted rules and let the cascade take care of this for you. Place the popup in the wrapper with the detailed name you like.
<div id="myPopupDivWithCommonIds"> </div>
And assign your css rules to this div.
#myPopupDivWithCommonIds .error { color: bright-pink; } #myPopupDivWithCommonIds #main { width: 93.21%; }
Etc. etc. This will take care of css rules and prevent overflow of your new stuff. You will need to make sure that none of the other rules leak out; the best way to do this is to intelligently rewrite any properties that are defined (as Pekka said). You can also use the kernel version and include a custom “reboot” or “bootstrap” style sheet and redirect all your rules to your new popup div again (as you said, this is difficult for 20k css lines, but includes another file with reset rules aimed at to your div, adding the #id selector as described above helps a bit.)
Oh, and this still does not solve the problem of duplicate identifiers, which are technically invalid markups and, most likely, prevent any JavaScript that you try to run on this page.
If that sounds like a mess, well, it is. Your developers and designers got to this point and did not receive serious refactoring, you will not return to a clean solution. An IFrame may seem hacked or impossible for your use case, but it will really remove a lot of your correctly anticipated problems.
source share