To export code as HTML, do File->Export->To HTML. If I interpreted your second question right, to write output from your program to an HTML file, just do some file I/O.
"Always program as if the person who will be maintaining your program is a violent psychopath that knows where you live."
--Martin Golding