DEV Community

Rajab Mohamed
Rajab Mohamed

Posted on • Edited on

Difference between textContent vs innerText

  1. innerText was non-standard, textContent was standardized earlier.

  2. innerText returns the visible text contained in a node, while textContent returns the full text. For example, on the following HTML
    <span>Hello <span style="display: none;">World</span></span>
    innerText will return 'Hello', while textContent will return 'Hello World'.

  3. As a result, innerText is much more performance-heavy: it requires layout information to return the result.

Top comments (2)

Collapse
 
_bkeren profile image
''

where is the following HTML Hello World example?

Collapse
 
ragabmohamedragab profile image
Rajab Mohamed

Thanks , I edited It .