---
url: /docs/guide/usage/linter/rules/jsx_a11y/iframe-has-title.md
---

### 它的作用

强制 iframe 元素具有 title 属性。

### 为什么这不好？

屏幕阅读器用户依赖 iframe 的 title 来描述 iframe 的内容。
如果标记中不包含 title 属性，对于这类技术的用户来说，快速在 iframe 和 iframe 元素之间导航会变得困难且令人困惑。

### 示例

以下是此规则的**错误**代码示例：

```jsx
<iframe />
<iframe {...props} />
<iframe title="" />
<iframe title={''} />
<iframe title={``} />
<iframe title={undefined} />
<iframe title={false} />
<iframe title={true} />
<iframe title={42} />
```

以下是此规则的**正确**代码示例：

```jsx
<iframe title="This is a unique title" />
<iframe title={uniqueTitle} />
```

## 如何使用

## 版本

此规则添加于 v0.0.19。

## 参考资料
