Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![MIHA W.LEE](https://secure.gravatar.com/avatar/01b9eb74a56c7acc35cd19d607c2b2b3?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
MIHA W.LEE
PHP Development Techdegree Graduate 25,452 PointsInnerHTML and textContent
I already watch the tutorial, but both sides can change text, whats the really difference between this two? Thank you so much.
1 Answer
![Kieran Barker](https://secure.gravatar.com/avatar/9ef4608014688520c96713201a96b1be?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Kieran Barker
15,028 PointsThe innerHTML
property lets you insert HTML into an element, whereas the textContent
property only lets you insert text.
If I had a div
element and I set its innerHTML
to <h1>Title</h1>
, then this new H1 element would be inserted into the element. But if I used textContent
, then the H1 opening and closing tags would literally just show as text and would not be rendered as an H1 element in the HTML.
MIHA W.LEE
PHP Development Techdegree Graduate 25,452 PointsMIHA W.LEE
PHP Development Techdegree Graduate 25,452 PointsThank you so much!! You explained very detailed!