Skip to content

no-nested-style-tag

Reports a <style> that is inside an element.

Only the <style> at the top level of a component is compiled as its CSS; a nested one is put into the page as an ordinary element, and its rules are not scoped to the component.

To fix, move the <style> to the top level.

Reported
...
<div><style>a { color: red }</style></div>
...
<a href="https://x.org" target="_blank" rel="noopener noreferrer">x</a>
...
After the fix
...
<div><style>a { color: red }</style></div>
...
<a href="https://x.org" target="_blank" rel="noopener noreferrer">x</a>
...
angular:
lint:
rules:
no-nested-style-tag: warn # off (default), warn, error
html:
lint:
rules:
no-nested-style-tag: warn # off (default), warn, error
svelte:
lint:
rules:
no-nested-style-tag: warn # off (default), warn, error
vue:
lint:
rules:
no-nested-style-tag: warn # off (default), warn, error

Suppress one line with sudsy-disable-next-line no-nested-style-tag in a comment of the file’s language.

The same check in other tools; Sudsy reports what each upstream rule reports.

Tool Rule Match
eslint-plugin-svelte no-nested-style-tag full