Re: Insulating part of a HTML document from global CSS

On Sun, Nov 17, 2013 at 2:11 AM, Tom Wardrop <tom@tomwardrop.com> wrote:
> Scoped stylesheets would be sufficient if there was either an easy way to
> reset all styles back to their browser defaults, or you could use scoped
> styles to not inherit anything from outer styles.
>
> Shadow DOM would work, but the problem with Shadow DOM and associated
> components is their complexity and the required boilerplate. I don't know
> how helpful it would be in the case of displaying, for example, the contents
> of an email inline.
>
> Being able to use scoped stylesheets in a way that disables inheritance from
> outer styles would address a number of issues faced today. Shadow DOM still
> has it's place as it seems to provide complete isolation including script
> isolation, not just style and DOM isolation, but it's overkill for the
> majority of simpler use cases.
>
> Web technologies should be generic and unassuming in my opinion. Things like
> Shadow DOM smell of "framework". Frameworks should be implemented at the
> layer above "browser-space" and should be the responsibility of the web
> developer rather than the browser vendors.

You've probably just been reading too much about Polymer or Brick,
which *are* frameworks.  (Or maybe just our attempts at explaining
what Web Components are for, which frequently invokes frameworks since
you're currently required to use them to get similar benefits.)

Putting together a simple web component that just pulls its light-DOM
contents into its own shadow is pretty simple and easy, and does
everything you need - the email will be protected from outside styles,
and it's styles won't be able to leak out, either.

~TJ

Received on Sunday, 17 November 2013 16:24:40 UTC