This translation is incomplete. Please help translate this article from English

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.

Note: innerText is easily confused with Node.textContent, but there are important differences between the two. Basically, innerText is aware of the rendered appearance of text, while textContent is not.


const renderedText = htmlElement.innerText
htmlElement.innerText = string


A DOMString representing the rendered text content of an element. If the element itself is not being rendered (e.g detached from the document or is hidden from view), the returned value is the same as the Node.textContent property.


This example compares innerText with Node.textContent. Note how innerText is aware of things like <br> elements, and ignores hidden elements.


<h3>Source element:</h3>
<p id="source">
  <style>#source { color: red; }</style>
Take a look at<br>how this text<br>is interpreted
  <span style="display:none">HIDDEN TEXT</span>
<h3>Result of textContent:</h3>
<textarea id="textContentOutput" rows="6" cols="30" readonly>...</textarea>
<h3>Result of innerText:</h3>
<textarea id="innerTextOutput" rows="6" cols="30" readonly>...</textarea>


const source = document.getElementById('source');
const textContentOutput = document.getElementById('textContentOutput');
const innerTextOutput = document.getElementById('innerTextOutput');

textContentOutput.innerHTML = source.textContent;
innerTextOutput.innerHTML = source.innerText;



Specification Status Comment
HTML Living Standard
La definición de 'innerText' en esta especificación.
Living Standard Introduced, based on the draft of the innerText specification. See whatwg/html#465 and whatwg/compat#5 for history.

Browser compatibility

Update compatibility data on GitHub
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome para AndroidFirefox para AndroidOpera para AndroidSafari en iOSSamsung Internet
innerTextChrome Soporte completo 1Edge Soporte completo 12Firefox Soporte completo 45IE Soporte completo 5.5Opera Soporte completo 9.6Safari Soporte completo 3WebView Android Soporte completo 4.4Chrome Android Soporte completo 18Firefox Android Soporte completo 45Opera Android Soporte completo 10.1Safari iOS Soporte completo 4Samsung Internet Android Soporte completo 1.0


Soporte completo  
Soporte completo

See also