---
url: /docs/guide/usage/linter/rules/unicorn/prefer-dom-node-text-content.md
---

### What it does

Enforces the use of `.textContent` over `.innerText` for DOM nodes.

### Why is this bad?

There are some disadvantages of using `.innerText`.

* `.innerText` returns rendered text and ignores hidden content, while `.textContent` returns the node's full text content.
* `.innerText` can trigger reflow because it takes CSS styles into account.
* `.innerText` is defined only for HTMLElement objects, while `.textContent` is defined for all Node objects.

### Examples

Examples of **incorrect** code for this rule:

```javascript
const text = foo.innerText;
```

Examples of **correct** code for this rule:

```javascript
const text = foo.textContent;
```

## How to use

## Version

This rule was added in v0.0.21.

## References
