Basically, your widget should be like a weaker version of the shadow DOM of replaced elements (buttons, textboxes etc), you supply good default styles but they have to be overridable by the page.
I can tell that you've never had to deal with this problem before. :)
Ignoring useragent styles for a moment, it's not uncommon for pages to declare broad styles like:
p { text-shadow: 0 1px 0 #000; }
h1, h2, h3 { text-transform: uppercase; }
a { color: red; }
input { margin-bottom: 2em; }
And it's likely that these styles are perfectly readable on the page. Now the author adds your widget, and suddenly your widget is also subject to these styles. If your widget is complex – think "mini app", not "ad unit" – you now have to reset every single possible CSS property for the widget to be usable on every site, and in a way that gives it the highest specificity compared to other selectors used by other page styles.I wasn't thinking inherit: none would disable a useragent's default styles. Just other styles directly on the page. But it's certainly not that simple to define those semantics.
You just apply that to each property you want to reset. You might think that applying it to EVERY property is a nightmare but in many cases you wouldnt need to. Disqus, for example, operates in your own CSS so it can look native to the page. They only have to override a few properties to assure their layout is good.
So yeah, while `inherit:none` would be awesome, I think `prop: initial` gets us most of the way there.
Also related: https://github.com/premasagar/cleanslate
1. Supporting IE7, for which people tend to use an intermediate Flash object to do the communication.
2. There's still the content size problem. Does your IFRAME'd widget change size? Now you need to detect all size changes with JavaScript and send them back to the host page so it can resize the IFRAME.
3. Is your widget non-rectangular or concave? For instance, can it pop out a menu of a different size than the widget itself? Well, now you need an additional IFRAME for each piece that sticks out.
There is absolutely no way to "silo" any area of a page from rogue CSS selectors besides using an IFRAME. Even the <style scoped> feature [1] which isn't even supported yet (AFAIK) doesn't really address the issue. The result is that you're constantly building a bigger and bigger localized CSS reset for your widget and trying to win the specificity arms-race against the host page.
I would love that feature.
[1] http://dev.w3.org/html5/spec-author-view/the-style-element.h...