what does the innertext give you?

3 weeks ago 1
Nature

The innerText property gives you the visible text content of an HTML element as it appears on the screen. It excludes any hidden text (such as text inside elements styled with display: none) and ignores HTML tags or markup, returning only what the user would see if they highlighted the element's content. Unlike innerHTML, which returns the HTML markup, innerText focuses solely on the rendered and visible text. In summary:

  • innerText returns the user-visible text inside an element.
  • It excludes hidden text and HTML tags.
  • It reflects the text as rendered by the browser, including respecting line breaks and styling.

This makes innerText useful for obtaining or setting the plain visible text in web page elements without any HTML formatting or hidden content.