Example
An editable paragraph:
这是一个可编辑的段落。
Browser support
##All major browsers support the contenteditable
The contenteditable attribute specifies whether the content of the element is editable.
Note: If the element does not set the contenteditable attribute, the element will inherit this attribute from its parent element.
Differences between HTML 4.01 and HTML5
The contenteditable attribute is new in HTML5.
Syntax
Attribute value
Description | |
Specifies that the element is editable. | |
Specifies that the element cannot be edited. |
When we click on an input box, it will actually generate a selection object - selection (that is, the area where the text we can see turns blue), selection is in
Firefox The toolcan be obtained directly using window.getSelection(). In HTML, there is only one selection, and selection is an area. You can imagine it as a rectangle, which has a beginning and an end.When When you click on an input box or switch to another input box, the selection will change accordingly. The cursor is inside the selection. The cursor is called range. It is a fragment area. Like selection, it has a starting point and an ending point. When we press the left button on the text and pull it to the right, we will see that the text turns blue. That is the start and end of the cursor. When we click directly, the cursor flashes, but in fact it is just the start and end points that overlap.
OK, now let’s actually operate the cursor. Just look at the complete code and see the effect.
The above is the detailed content of HTML attribute contenteditable that specifies whether the content of an element is editable. For more information, please follow other related articles on the PHP Chinese website!