Home  >  Article  >  Web Front-end  >  HTML5 attribute spellcheck specifies whether to perform spelling and grammar checks on elements

HTML5 attribute spellcheck specifies whether to perform spelling and grammar checks on elements

黄舟
黄舟Original
2017-11-03 13:38:283324browse

Example

Editable paragraph for spell check:

<p contenteditable="true" spellcheck="true">这是一个段落。</p>

Browser support

IE, Firefox, Chrome, SafariOpera

Definition and usage

spellcheck AttributeSpecifies whether to check spelling and grammar on the element.

You can spell check the following:

  • Text value (non-password) in the input element

  • 59f40b15d06ee3f6e7f1174ca1d8f40b elements

  • Text in editable elements

Differences between HTML 4.01 and HTML5

The spellcheck attribute is a new attribute in HTML5.

Syntax

<element spellcheck="true|false">

Attribute value

Value Description
true Check elements for spelling and grammar
false Do not check elements.

html5 spellcheck attribute (spelling, grammar check)

<!DOCTYPE html> 
<html> 
<head> 
<meta charset="utf-8" /> 
<title>spellcheck属性的使用</title> 
</head> 
<body> 
<style>
.ac{border:1px solid #ff7300;width:200px;height:100px;}
</style>
<pre class="brush:php;toolbar:false">
1.<b>输入完某个单词后,进行按空格键,就可以看到这是不是错误的单词了。</b>
2.spellcheck="true"、&#39;false&#39;、"",值为true和""时,代表检查。。
【空字符串为什么检查:就跟input其他属性一样,你设置个readonly就是只读( readonly=""),再加个值描述的更准确。】
3.使用场合:
   1.类型为text型的input元素,但input类型为text型的input元素,但input="password"不行(原因:你是密码哎,都是星号还检查个啥玩意,密码本身就是不同字母组合而出的)。
   2.textarea元素
   3.spellcheck属性,html5中的所有元素都可以指定,对于不是输入栏的元素,须指定contenteditable="true" 编辑属性,才能使用。(如div什么的。)
4.现代浏览器都支持以及IE10   

检测

不检测

div absolute testK

readonly="":

The above is the detailed content of HTML5 attribute spellcheck specifies whether to perform spelling and grammar checks on elements. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn