Skip to content

no-inline-style

Reports a style attribute, and a Svelte style:property directive. A style that sets only display is not reported, because scripts toggle it.

Styles in attributes cannot be shared between elements and pages, outweigh every rule of a stylesheet, and are blocked by a strict content security policy.

To fix, use a class and a stylesheet.

Reported
...
<body>
...
<p title='say "hi"' style="color: red">ok</p>
<p style="display: none">ok</p>
...
<br>
...
angular:
lint:
rules:
no-inline-style: warn # off (default), warn, error
html:
lint:
rules:
no-inline-style: warn # off (default), warn, error
svelte:
lint:
rules:
no-inline-style: warn # off (default), warn, error
vue:
lint:
rules:
no-inline-style: warn # off (default), warn, error

Enabled by the presets: html/html-validate-recommended, html/htmlhint.

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

The same check in other tools. full: Sudsy reports what the upstream rule reports; partial: only part of it, as the last column says.

Tool Rule Match What differs
angular-eslint no-inline-styles full
eslint-plugin-svelte no-inline-styles full
html-eslint no-inline-styles partial a style that sets only display is allowed
html-validate no-inline-style partial a style that sets only display is allowed; the allowedProperties and allowVariables options are not available
htmlhint inline-style-disabled partial a style that sets only display is allowed