" /> " /> "/>

Why this InnerHtml returning same output as innerText

45 Views Asked by At

(Beginner) The code below (css excluded) shows same output. But innerHtml should have given the output with html tag right?

HTML

    <div class="sunpath">
        <div class="sun"> SUN </div>
        <div class="planet">
           <div class="stable">
            Planet
           </div>
        </div>
    </div>

Javascript

p = document.querySelector(".sun");
console.log(p.innerHTML);
console.log(p.innerText); 

In console (firefox) both gives the same outputScreenshot

1

There are 1 best solutions below

0
Mikael Tenshio On BEST ANSWER

you are right bro: because u r accessing the parent tag:

if you have do this

   <div class="sun"><p> SUN </p></div>

then tag would be also console