Skip to main content

a11y/useIframeTitle

enforce iframe elements have a title attribute

ESLint Equivalent: iframe-has-title

Examples

Invalid

<iframe />

 file.tsx:1 lint/a11y/useIframeTitle ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  Provide a title attribute when using iframe elements.

    <iframe />
    ^^^^^^^^^^

  Screen readers rely on the title set on an iframe to describe the
    content being displayed.


<iframe {...props} />

 file.tsx:1 lint/a11y/useIframeTitle ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  Provide a title attribute when using iframe elements.

    <iframe {...props} />
    ^^^^^^^^^^^^^^^^^^^^^

  Screen readers rely on the title set on an iframe to describe the
    content being displayed.


<iframe title="" />

 file.tsx:1 lint/a11y/useIframeTitle ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  Provide a title attribute when using iframe elements.

    <iframe title="" />
    ^^^^^^^^^^^^^^^^^^^

  Screen readers rely on the title set on an iframe to describe the
    content being displayed.


<iframe title={""} />

 file.tsx:1 lint/a11y/useIframeTitle ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  Provide a title attribute when using iframe elements.

    <iframe title={""} />
    ^^^^^^^^^^^^^^^^^^^^^

  Screen readers rely on the title set on an iframe to describe the
    content being displayed.


<iframe title={``} />

 file.tsx:1 lint/a11y/useIframeTitle ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  Provide a title attribute when using iframe elements.

    <iframe title={``} />
    ^^^^^^^^^^^^^^^^^^^^^

  Screen readers rely on the title set on an iframe to describe the
    content being displayed.


<iframe title={undefined} />

 file.tsx:1 lint/a11y/useIframeTitle ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  Provide a title attribute when using iframe elements.

    <iframe title={undefined} />
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  Screen readers rely on the title set on an iframe to describe the
    content being displayed.


<iframe title={false} />

 file.tsx:1 lint/a11y/useIframeTitle ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  Provide a title attribute when using iframe elements.

    <iframe title={false} />
    ^^^^^^^^^^^^^^^^^^^^^^^^

  Screen readers rely on the title set on an iframe to describe the
    content being displayed.


<iframe title={true} />

 file.tsx:1 lint/a11y/useIframeTitle ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  Provide a title attribute when using iframe elements.

    <iframe title={true} />
    ^^^^^^^^^^^^^^^^^^^^^^^

  Screen readers rely on the title set on an iframe to describe the
    content being displayed.


<iframe title={42} />

 file.tsx:1 lint/a11y/useIframeTitle ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  Provide a title attribute when using iframe elements.

    <iframe title={42} />
    ^^^^^^^^^^^^^^^^^^^^^

  Screen readers rely on the title set on an iframe to describe the
    content being displayed.

<iframe></iframe>

 file.html:1 lint/a11y/useIframeTitle ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  Provide a title attribute when using iframe elements.

    <iframe></iframe>
    ^^^^^^^^^^^^^^^^

  Screen readers rely on the title set on an iframe to describe the
    content being displayed.


<iframe title=""></iframe>

 file.html:1 lint/a11y/useIframeTitle ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  Provide a title attribute when using iframe elements.

    <iframe title=""></iframe>
    ^^^^^^^^^^^^^^^^^^^^^^^^^

  Screen readers rely on the title set on an iframe to describe the
    content being displayed.

Valid

<iframe title='title' />
<Iframe title='title' />
<iframe title="Tour"></iframe>
<iframe title="Camping"></iframe>