empty-attr-value¶
Added in NEXT_DJANGOFMT_VERSION · Related issues · View source
Fix is always available.
What it does¶
Checks for empty id or class attribute values on HTML elements.
Why is this bad?¶
An id="" or class="" attribute is almost always unintentional: no CSS class selector
matches an element with an empty class, and document.getElementById("") returns nothing.
Removing the attribute reduces template noise.
Example¶
Use instead:
Fix safety¶
The fix is marked as safe. In practice, removing an empty id/class preserves rendering
in every realistic template. The DOM technically distinguishes <div id=""> from
<div> (hasAttribute("id"), the attribute selector [id=""]), but author code relying
on those forms is vanishingly rare.