Re: Reseting CSS on div

On Thu, Oct 23, 2014 at 3:51 AM, Bruce Lawson <brucel@opera.com> wrote:
> On 23 October 2014 11:36, Behrang Saeedzadeh <behrangsa@gmail.com> wrote:
>> Hi,
>>
>> Have there been any discussions to allow defining a div that ignores any
>> styling defined outside it and only honors <style> tags defined within it?
>
> Isn't that what div { all:initial }  is for?
> http://dev.w3.org/csswg/css-cascade/#all-shorthand

No, that blocks *inheritance* and anything setting styles directly on
the <div> itself, but it does nothing for the contents of the <div>.

(Also, it's terrible, because it means the <div> is, for example, set
to display:inline.  We really need the "default" keyword that only
ignores author styles.)

Behrang, what you want is Shadow DOM, which does precisely this -
unless you use special combinators to pierce into the shadow DOM, no
styles from outside can reach in (and no styles from inside ever reach
out, no matter what you do).

~TJ

Received on Thursday, 23 October 2014 21:34:30 UTC