Think about it: what does encoded HTML look like? For example, it might look like this:
<a href="www.stackoverflow.com">
Thus, it will be displayed on the client as literals (as <a href = "www.stackoverflow.com">), and not as HTML. This means that you will not see the actual link, but the code itself.
XSS attacks work on the basis that someone can force the browser browser to parse HTML code that the site provider was not going to do there; if the above was not encoded, this would mean that the provided link would be embedded in the site, although the site provider did not want this.
XSS, of course, is a bit more complicated than that, and usually includes JavaScript (which means Cross Site Scripting ), but for demo purposes this simple example should be sufficient; this is the same with JavaScript code as it is with simple HTML tags, since XSS is a special case of more general HTML insertion.
source share