How in the world do I paste code?

How in the world do I paste code?

Why does it automatically remove all line breaks when I paste in code?

For example when I paste in something like this:

<div>123123</div>
<div>123123</div>
<div>123123</div>

After I post the message, it turns into this??

<div>123123</div><div>123123</div><div>123123</div>

If I try to manually separate them, then each line turns into this huge empty code block.