Source Attribute Required

ID

html.src_attribute_required

Severity

low

Remediation Complexity

low

Remediation Risk

low

Remediation Effort

low

Resource

Reliability

Language

Html

Tags

reliability

Description

Flags resource-loading elements that declare no source: an <img> with neither src nor srcset, an <iframe> with neither src nor srcdoc, an <embed> with no src, and a <track> with no src.

Rationale

An element that points at no resource is dead markup — it occupies space in the DOM but renders nothing useful, which usually signals a mistake such as a forgotten attribute or a broken template.

<img alt="x">                       <!-- FLAW — no src or srcset -->
<iframe></iframe>                   <!-- FLAW — no src or srcdoc -->

<img src="a.png" alt="x">           <!-- OK — has src -->
<img srcset="a.png 1x" alt="x">     <!-- OK — has srcset -->
<iframe src="/p"></iframe>          <!-- OK — has src -->

Remediation

Add the appropriate source attribute (src, or srcset/srcdoc where applicable) pointing at the resource the element should load, or remove the element if it is not needed.