Yes, absolutely.
On forums, I sometimes do either, partly out of laziness, and partly out of limitations of the medium. For technical writing, the space is indeed the correct, and better looking, way to do.

Note that it needs to be a non-breaking thin space. In Unicode, this either uses a normal thin space (I don't remember if it is breaking or not), or non-breaking 'glue' zero-width-spaces to hold it together. In HTML, you might also put it in a non-breaking <span>.
In \$\LaTeX\$, I use a macro which puts the expression in math mode, with the unit in \textrm{} so it looks right and doesn't break. (Math mode isn't necessary for writing out simple numbers, but makes it easier to write short expressions, and units with odd powers or ratios).
Tim