spellcheck
spellcheck 全局属性是枚举属性,定义是否可以检查元素的拼写错误。它可以具有以下值:
true, 设置在可能的情况下会去检查元素内容的拼写错误;false, 设置在可能的情况下关闭对元素内容拼写检查。
如果没有设置这个属性,默认值由元素自身类型和浏览器设置决定。默认值也可以被继承,当有祖先元素的 spellcheck 设置为 true 的情况下,子元素的默认值也是 true。
你可以参考这篇文章的例子来使用这个属性。
这个属性是枚举型而不是布尔类型。这意味着显式设置其中一个值 true 或 false 是强制性的,如果使用简写 <label spellcheck>Example Label</label> 是不行的。正确的用法是<label spellcheck="true">Example Label</label>.
这个属性仅仅是浏览器上的提示:浏览器并不会强制去检查拼写错误,通常不可编辑的元素是不会去检查拼写错误的,就算它的 spellcheck 属性被设置为 true 而且浏览器支持拼写检查。
各个浏览器的默认设置和元素依赖:
| 浏览器 | <html> |
<textarea> |
<input> |
其他 | 附注 |
|---|---|---|---|---|---|
| Firefox | false |
false |
false |
inherited | 当 layout.spellcheckDefault 值为 0 |
false |
true |
inherited | inherited | 当 layout.spellcheckDefault 值为 1 (default
value) |
|
false |
true |
true |
inherited | 当 layout.spellcheckDefault 值为 2 |
|
| Seamonkey | false |
false |
false |
inherited | 当 layout.spellcheckDefault 值为 0 |
false |
true |
inherited | inherited | 当 layout.spellcheckDefault 值为 1(默认如此) |
|
false |
true |
true |
inherited | 当 layout.spellcheckDefault 值为 2 |
|
| Camino | false |
false |
false |
inherited | 当 layout.spellcheckDefault 值为 0 |
false |
true |
inherited | inherited | 当 layout.spellcheckDefault 值为 1 |
|
false |
true |
true |
inherited | 当 layout.spellcheckDefault 值为 2(默认如此) |
|
| Chrome | false |
true |
? | inherited | |
| Internet Explorer | false |
true |
? | inherited | |
| Opera | false |
true |
? | inherited | |
| Safari | false |
true |
? | inherited |
规范
| Specification |
|---|
| HTML Standard # attr-spellcheck |
浏览器兼容性
BCD tables only load in the browser
另见
- 所有 全局属性