Home > Web Front-end > H5 Tutorial > body text

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

黄舟
Release: 2017-11-03 13:38:28
Original
3368 people have browsed it

Example

Editable paragraph for spell check:

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

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

  • < Text in textarea> 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">
Copy after login

Attribute value

ValueDescription
trueCheck elements for spelling and grammar
falseDo 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="":

Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!