One option is to embed your widget inside an iframe; as such, no styles from the surrounding document get inherited. This is the method used by many social widgets, such as share buttons, so that there isn't any style interference.
There are CSS-only options beginning to be rolled out. Safari supports:
.widget { all: revert; )
which does exactly what you're after. There's greater support for:
.widget { all: initial; )
which is supported by all modern browsers (not Internet Explorer) but strips styles back beyond the browser defaults (e.g. <div>
s will become inline), so you will have to add those back in - for example:
.widget block { display: block; }
But at least you won't get style clash.
https://developer.mozilla.org/en-US/docs/Web/CSS/initial
https://developer.mozilla.org/en-US/docs/Web/CSS/revert