Skip to content

noInlineStyles (HTML)

biome.json
{
"linter": {
"rules": {
"nursery": {
"noInlineStyles": "error"
}
}
}
}

Disallow the use of inline styles.

Inline styles via the style attribute make code harder to maintain and override, prevent reusability of styling, and can be a security concern when implementing a strict Content Security Policy (CSP).

Instead of inline styles, use CSS classes, CSS modules, or a styling library.

<div style="color: red;"></div>
code-block.html:1:6 lint/nursery/noInlineStyles  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

ℹ Unexpected style attribute.

> 1 │ <div style="color: red;"></div>
│ ^^^^^^^^^^^^^^^^^^^
2 │

ℹ Inline styles make code harder to maintain, reduce reusability, and can prevent effective use of a strict Content Security Policy. Use external CSS classes or stylesheets instead.

ℹ This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

ℹ Unsafe fix: Remove the style attribute.

1 │ <div·style="color:·red;"></div>
│ -------------------
<p style="font-size: 14px;">Hello</p>
code-block.html:1:4 lint/nursery/noInlineStyles  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

ℹ Unexpected style attribute.

> 1 │ <p style="font-size: 14px;">Hello</p>
│ ^^^^^^^^^^^^^^^^^^^^^^^^
2 │

ℹ Inline styles make code harder to maintain, reduce reusability, and can prevent effective use of a strict Content Security Policy. Use external CSS classes or stylesheets instead.

ℹ This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

ℹ Unsafe fix: Remove the style attribute.

1 │ <p·style="font-size:·14px;">Hello</p>
│ ------------------------
<div class="text-red"></div>
<p class="body-text">Hello</p>