<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Luana Sherman on Medium]]></title>
        <description><![CDATA[Stories by Luana Sherman on Medium]]></description>
        <link>https://medium.com/@lugamoreira?source=rss-f42b7d3a815a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*pqPz6Av7xcbumwXqqnYRfA@2x.jpeg</url>
            <title>Stories by Luana Sherman on Medium</title>
            <link>https://medium.com/@lugamoreira?source=rss-f42b7d3a815a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 00:21:37 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@lugamoreira/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[The Little Big Differences Between innerText, innerHTML, and textContent.]]></title>
            <link>https://medium.com/@lugamoreira/the-little-big-differences-between-innertext-innerhtml-and-textcontent-61e10849d9b2?source=rss-f42b7d3a815a------2</link>
            <guid isPermaLink="false">https://medium.com/p/61e10849d9b2</guid>
            <category><![CDATA[html]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[innerhtml]]></category>
            <category><![CDATA[innertext]]></category>
            <category><![CDATA[css]]></category>
            <dc:creator><![CDATA[Luana Sherman]]></dc:creator>
            <pubDate>Wed, 04 Jan 2023 07:10:53 GMT</pubDate>
            <atom:updated>2023-01-04T15:51:49.407Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1CR_dlHywlKu_srhNx81lg.png" /></figure><p>You probably already caught yourself wondering why people tell you to use <em>textContent</em> or <em>innerText </em>but to avoid <em>InnerHtml </em>when you are at the beginning of your journey as a programmer, well I am here to help you understand why we do that and when it is best to use each one of those properties.</p><p>I will start by showing you the HTML code I wrote, as you will see, it contains the style and script tag on it.</p><pre>&lt;div id=&quot;text&quot;&gt;<br>    This are the &lt;strong&gt;differences&lt;/strong&gt; between &lt;em&gt;innerText&lt;/em&gt;, innertHtml and &lt;strong&gt;textContent&lt;/strong&gt;<br> &lt;style&gt;<br>        #text {<br>            text-transform: uppercase;<br>          }<br>          &lt;/style&gt;<br>    &lt;script&gt;<br>            var text = document.getElementById(&#39;text&#39;);<br>            console.log(text.innerText);<br>            console.log(text.innerHTML);<br>            console.log(text.textContent);<br>          &lt;/script&gt;<br>&lt;/div&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/672/1*gxjzThPJEVDgaGCW6m_o6A.png" /><figcaption>this is what the user sees on the webpage</figcaption></figure><p>Let’s see what i<em>nnerText </em>will retrieve:</p><pre>var text = document.querySelector(&#39;#text&#39;);<br>text.innerText <br>// =&gt; &quot;THIS ARE THE DIFFERENCES BETWEEN INNERTEXT, INNERHTML AND TEXTCONTENT&quot;</pre><p>The <em>innerText </em>property retrieves text as the user sees it, it will not retrieve any hidden properties inside our code like style and script. It is the least used one of all three as it is much more performance-heavy, it requires layout information to return the result, so it is not as used as the other two properties.</p><p>Now, let’s see what <em>textContent </em>will retrieve:</p><pre>text.textContent <br>// =&gt;        This are the differences between innerText, innerHtml and textContent<br>//        <br>//        #text {<br>//            text-transform: uppercase;<br>//          }<br>//           <br>//          <br>//            var text = document.getElementById(&#39;text&#39;);<br>//            console.log(text.innerText);<br>//            console.log(text.innerHTML);<br>//            console.log(text.textContent);</pre><p>As you can see, <em>textContent </em>retrieves all the content within the element, including all of its children&#39;s, it does not take into consideration any of the CSS or formatting when showing you the text content.</p><p><em>textContent </em>is the easiest way to get rid of all child elements without compromising your page with <em>innerHTML </em>or making it as performance-heavy as <em>innerText</em>.</p><p>Finally, <em>innerHTML</em>:</p><pre>text.innerHTML <br>//         This are the &lt;strong&gt;differences&lt;/strong&gt; between &lt;em&gt;innerText&lt;/em&gt;, innerHtml and &lt;strong&gt;textContent&lt;/strong&gt;<br>//        &lt;style&gt;<br>//       #text {<br>//            text-transform: uppercase;<br>//          }<br>//          &lt;/style&gt; <br>//          &lt;script&gt;<br>//            var text = document.getElementById(&#39;text&#39;);<br>//            console.log(text.innerText);<br>//            console.log(text.innerHTML);<br>//            console.log(text.textContent);<br>//          &lt;/script&gt;</pre><p>Again <em>innerHTML </em>will retrieve the same information as textContent but also all the formatting that you added to your HTML. It can be used to change the whole HTML element that you selected and add some HTML straight from your JavaScript, but you should always ask yourself this question before using it:</p><ul><li>Will this change be <strong>hardcoded</strong> on my javascript and I can trust it or will it be <strong>provided by the user</strong>?</li></ul><p>An example of that is when you want to add to your webpage something that the user typed on a form, in this case, you will be better off using <em>textContent</em>.</p><p>I hope you could understand a bit better about those three JavaScript properties and their little big differences!</p><p>Please leave me a comment if there is anything I left out of this blog as I am only a student and will always love to learn more!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=61e10849d9b2" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>