The HTML
element defines a piece of programming code:Example
<code>
var x = 5;
var y = 6;
document.getElementById("demo").innerHTML = x + y;
</code>
Result:
var x = 5; var y = 6; document.getElementById("demo").innerHTML = x + y;
Notice that the
element does not preserve extra whitespace and line-breaks.
To fix this, you can put the
element inside a
element:
Example
<pre>
<code>
var x = 5;
var y = 6;
document.getElementById("demo").innerHTML = x + y;
</code>
</pre>
Result:
var x = 5;
var y = 6;
document.getElementById("demo").innerHTML = x + y;
EmoticonEmoticon