Adding code snippets to HTML

Adding code snippets to HTML


Hi guys,
I’m terribly confused on how to add code snippet spacing and new lines.
For example if I had this set of code, all I can think of is to use <//br> & &nbsp.
I’m missing the semi-colons so it doesn’t implement nbsp by the way guys, not sure of how else to explain my problem on this forum aha.

   &nbsp if ifStatementTurd (testTurd === 10) {<br>
    &nbsp&nbsp console.alert(turdBlowingUp);<br>
  &nbsp  ifStatementTurd(10);

Any help on the best way to implement code snippets is greatly appreciated!


I’m having a hard time understanding your question.
A code snippet in html? Like this? (I used pre tag to keep the spacing)

A piece of computer code
more code
more code</pre></code>


Are you trying to add Javascript to your HTML document?

You need to put your JS in <script> tags. No br or nbsp needed.

Or if you mean what hbar1st said, do that.


Pre tags, thank you! That’s what I was trying to say lol. I wanted to keep the spacing!