W3cubDocs

/DOM

HTMLElement.innerText

The innerText property of the HTMLElement interface represents the "rendered" text content of a node and its descendants. As a getter, it approximates the text the user would get if they highlighted the contents of the element with the cursor and then copied it to the clipboard.

This feature was originally introduced by Internet Explorer, and was formally specified in the HTML standard in 2016 after being adopted by all major browser vendors.

Node.textContent is a somewhat similar alternative, although there are important differences between the two.

Syntax

elemInstance.innerText;
elemInstance.innerText = string;

Returns

A string representing the rendered text content of an element.

Examples

let string = 'Hello, I am pleased to see you';
const para = document.querySelector('p');

para.innerText = string;

Specification

Specification Status Comment
HTML Living Standard
The definition of 'innerText' in that specification.
Living Standard Introduced, based on the draft of the innerText specification. See whatwg/html#465 and whatwg/compat#5 for history.

Browser compatibility

No compatibility data found. Please contribute data for "api.HTMLElement.innerText" (depth: 1) to the MDN compatibility data repository.

See also

© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/innerText