W3docs

Atributo contenteditable de HTML

The contenteditable attribute is used to specify whether or not the content of an element is editable. Read about this attribute and see on what elements to use.

El atributo contenteditable de HTML se utiliza para especificar si el contenido de un elemento es editable o no.

Puedes usar este atributo en cualquier elemento HTML. Forma parte de los Atributos globales.

El atributo contenteditable acepta true, false o inherit. Una cadena vacía ("") también es válida y se comporta de manera idéntica a true. Si se omite el atributo, el elemento hereda el valor de su padre.

danger

El atributo contenteditable no tiene efecto en los elementos deshabilitados.

Sintaxis

Sintaxis del atributo contenteditable de HTML

<tag contenteditable="true|false">&lt;/tag&gt;

Ejemplo del atributo contenteditable de HTML:

Ejemplo del atributo "contenteditable" de HTML

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
  </head>
  <body>
    <p contenteditable="false">
      This is a paragraph. It is not editable.
    </p>
    <p contenteditable="true">
      This is a paragraph. It is editable. Try to change this text.
    </p>
  </body>
</html>

Práctica

Práctica

¿Cuáles de las siguientes afirmaciones son verdaderas respecto al atributo contenteditable de HTML?