HTML DOM Element outerText property

Definition and usage

outerText property sets or returns the text content of the specified node.

This property is similar to the internal innerText propertyIn fact, it retrieves outerText With the retrieval innerText The result returned by the property is the same.

Set the element's outerText There is an important difference when it is removed: the element itself will be removed.

Tip:See also outerHTML property.

Example

Set the external text of the element:

document.getElementById("myH1").outerText = "Changed content!";

Try it yourself

Syntax

Return the text content of the node:

node.outerText

Set the text content of the node (replaces the entire node):

node.outerText = text

Attribute value

Value Type Description
text String Specifies the text content to be inserted.

Return value

Type Description
String The text content of the node and all its descendants.

Browser support

The numbers in the table indicate the first browser version that fully supports this attribute.

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
43 11 Not Supported 6 61