Skip to content

prefer-tbody

Reports a <tr> that is directly in a <table>.

The browser puts it into an implied <tbody>, so the DOM differs from the markup, and a selector such as table > tr never matches.

To fix, write the <tbody>.

Reported
<!DOCTYPE html>
<title>x</title>
<table><tr><td>a</td></tr></table>
<table><tbody><tr><td>a</td></tr></tbody></table>
<main></main>
<main hidden></main>
...
angular:
lint:
rules:
prefer-tbody: warn # off (default), warn, error
html:
lint:
rules:
prefer-tbody: warn # off (default), warn, error
svelte:
lint:
rules:
prefer-tbody: warn # off (default), warn, error
vue:
lint:
rules:
prefer-tbody: warn # off (default), warn, error

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

Suppress one line with sudsy-disable-next-line prefer-tbody in a comment of the file’s language.

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

Tool Rule Match
html-validate prefer-tbody full