Enter <code>#INSERT CODE HERE </code> and put whatever you want inside the code brackets.

More info here: https://codex.wordpress.org/Writing_Code_in_Your_Posts

But that was not working at all for me. So I discovered that I could install the Prism Syntax Highlighter by Ankur Kumar, then follow the instructions on this stack overflow post which says:

Did a little playing around with this plugin and found that replacing < and > with > and < was kind of a pain. For what its worth if you wrap your html with a script tag, everything highlights. Because html inside of an untyped script tag doesn't play nice with Visual Studio, I gave it a type of prism-html-markup.

See the stock overflow link above for an example of the code.