When you write code in a text editor, you often format it for readability, adding indents for code inside of functions, if statements, loops, etc. HTML generally ignores these indents, so your code ends up all jammed to the left side of the screen. To keep your indents, you must put your code within preformat tags.
Long lines tend to get wrapped to the next line, making your code confusing or even incorrect if someone tries to use it. To keep your lines from wrapping, you must wrap your code in tags and apply a CSS style rule to the div, setting the overflow setting to auto. This will put your code in a box with a horizontal scroll bar.
Then there's special characters. The XHTML treats certain characters as special, interpreting them as control codes. To display these characters on a web page, you must replace them with their corresponding XHTML codes, which are:
< ( < )
> ( > )
& ( & )
" ( " )
&39; ( ' )
&124; ( | )