Bylaw.HTML.Check.NoInlineStyle (bylaw_html v0.1.0-alpha.2)

Copy Markdown View Source

Validates that rendered elements do not define inline style attributes.

This check inspects rendered HTML and flags any element with a style attribute. Prefer classes or attributes that keep styling in CSS.

Examples

Bad:

<div style="display: none">Menu</div>

Why this is bad:

Inline styles make visual behavior harder to reuse, override, test, and audit.

Better:

<div class="hidden">Menu</div>

Why this is better:

The styling is represented by a reusable class instead of embedded in the rendered markup.

Bad:

<button style="">Save</button>

Why this is bad:

An empty inline style still creates a style hook in rendered HTML.

Better:

<button class="button">Save</button>

Why this is better:

The element keeps styling concerns out of inline attributes.

Notes

This check flags any rendered style attribute, including empty values. It does not inspect stylesheet content or judge whether a class name has a matching CSS rule.

This check runs on rendered HTML, so dynamic style attributes are evaluated after rendering.

Options

This check has no check-specific options. Add the module directly to the explicit checks list:

Bylaw.HTML.Check.NoInlineStyle

Usage

Add this module to the explicit check list passed through Bylaw.HTML. See Bylaw.HTML for the full rendered HTML validation setup.

Summary

Functions

Implements the Bylaw.HTML.Check validation callback.

Functions

validate(context)

Implements the Bylaw.HTML.Check validation callback.