a11y/deprecated-attr · Deprecated HTML attribute
An attribute the HTML spec data marks deprecated on this element has its behavior defined by legacy compatibility, not by the standard.
Severity: info · Category: a11y
Scored info rather than warning: the attribute may still work today. The finding is that the standard no longer defines what it means, and a CSS or modern-attribute replacement exists.
What it checks
Flags an attribute the HTML spec data marks deprecated (or obsolete) on that element, such as iframe[frameborder], td[width], body[bgcolor], hr[size] and style[type], in component source.
Deprecation is per element: width is deprecated on <td> and current on <img>, so only the first is reported. An element with several deprecated attributes yields one finding listing them, anchored at the start tag, so one disable-next-line directive above the element silences it, however many lines the tag spans.
Not flagged:
- A deprecated attribute on an element
a11y/deprecated-elementreports (<font color>,<marquee behavior>): one finding per element. That holds even whena11y/deprecated-elementis off or suppressed inline: this rule skips obsolete elements by name. - Anything inside
<svg>, or in a component declaring<svelte:options namespace="svg" />; content under<foreignObject>returns to HTML. - The global attribute groups (
xml:lang,xlink:href,onwebkit*). Only an element’s own attribute table is consulted, so<use xlink:href="#icon">in an SVG sprite is never reported. - Attributes only marked
nonStandardorexperimental. One marked bothdeprecatedandnonStandard(hr[size]) is reported. - A component’s own
<style>block: it is the component stylesheet, not an element. A<style type="text/css">inside<svelte:head>is an element and is reported.
<iframe src="/embed" frameborder="0" title="Map"></iframe>
<td width="120">…</td>
Coverage follows the dataset, which is the deprecated/obsolete columns of the vendored HTML spec data (@markuplint/html-spec) and tracks MDN’s status rather than the WHATWG obsolete-features list. That cuts both ways: an attribute MDN marks deprecated is reported even where the standard’s word differs (a[attributionsrc]), and WHATWG-obsolete attributes MDN never documented, among them p[align], td[nowrap] and html[manifest], are not reported.
Why it matters
A deprecated attribute’s behavior is defined by what browsers still do for legacy pages, not by the standard, and each has a replacement whose behavior is defined, usually CSS and sometimes a modern attribute.
How to fix
Move the presentation to CSS, or use the attribute the deprecated one was superseded by:
<iframe src="/embed" title="Map" style="border: 0"></iframe>
<td style="width: 120px">…</td>
Mode differences
None. This rule reads source, the same .svelte and .ts files, everywhere it runs. The CLI, the Vite plugin’s build pass, and the live dashboard’s static baseline all report it identically, and the rendered-HTML pass never re-evaluates it. Scoping a run with --route skips it: component-scoped rules have no route to attribute a finding to.
Disabling
Silence a single element with <!-- svelte-vitals-disable-next-line a11y/deprecated-attr -->, or turn the rule off:
export default {
rules: {
'a11y/deprecated-attr': 'off'
}
};