While using ASP.NET controls, for example
<h1 id="header" runat="server">text</h1>
if we want to change the text of the header we can do it probably by two properties InnerHTML
and InnerText
. I want to know what is the basic difference between the two properties?
InnerHtml
lets you enter HTML code directly, InnerText
formats everything you put in there for it to be taken as plain text.
For example, if you were to enter this in both properties: Hello <b>world</b>
This is what you would get with InnerHTML:
Hello world
That is, exactly the same HTML you entered.
Instead, if you use InnerText
, you get this:
Hello <b>world</b>
And the resulting HTML would be Hello <b>world</b>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With