iframe-has-title
Configuration
Rule Details
This rule enforces that every <iframe> element carries a non-empty title
attribute so screen-reader users can identify the embedded frame's purpose.
An iframe without a usable title violates
WCAG 2.4.1 and
WCAG 4.1.2.
The element name is resolved through the standard jsx-a11y settings —
components and polymorphicPropName — so a custom component mapped to
iframe (e.g. <FooComponent /> with
settings: { 'jsx-a11y': { components: { FooComponent: 'iframe' } } })
is checked the same way as a literal <iframe> tag.
The title value is required to satisfy value && typeof value === 'string'.
Truthy non-string values (numbers, booleans, plain objects, arrays, RegExps,
functions) all fail this gate. Notably:
<iframe title />is reported (boolean attribute form coerces totrue).<iframe title={42} />and<iframe title={true} />are reported.- Empty-string forms —
<iframe title="" />,<iframe title={""} />, and the empty template literal — are all reported. <iframe title={undefined} />is reported.
Examples of incorrect code for this rule:
Examples of correct code for this rule: