Reading & Changing Content

Once you've selected an element, learn how to read its content, change its text, update attributes, and even create brand-new elements from scratch.

Step 1 of 5

textContent: read and write text

Every element has a `.textContent` property. Reading it gives you all the text inside the element (including text in child elements). Setting it replaces all the element's content with plain text.

This is the safest way to change text on a page because it treats everything as plain text — even if you accidentally include HTML tags, they'll appear as literal text, not rendered HTML. On sites like Twitter, YouTube, and Gmail, `textContent` is used constantly to update labels, counters, timestamps, and messages.

Think of it this way: Reading content is like looking at a sign on a door. Changing `textContent` is like replacing that sign with a new one — the door stays, but the message changes. No matter what you write on the sign, it's always treated as plain text.
Learn more on MDN
JAVASCRIPTREAD ONLY
CONSOLE
Click "Run" to execute your code...