132 of 133 menu

The contenteditable attribute

The contenteditable attribute allows you to make any page element editable via a browser.

The value true enables editing, and false disables it. Instead of true, you can specify an empty value or not write it at all.

You shouldn't think that after editing the changes on the page will be saved somewhere. This should be implemented independently via JavaScript.

Example

Let's edit the text of the paragraph through the browser (just click on it with the mouse and start writing):

<p contenteditable> The text of this paragraph can be edited via a browser. </p>

:

Example

Now let's disable text editing (to do this, you can omit the contenteditable attribute altogether):

<p contenteditable="false"> The text of this paragraph cannot be edited via a browser. </p>

:

See also

  • tag textarea,
    with which you can make a text editor
enru