Oh, I think if you write form$ to a html/tmpfile.html and then use the HtmlLoadFile command instead of HtmlLoadData, it will work. That is how the Contact Database demo program is written.
Don't forget to uncomment this statement.
' form$ = form$ + "<link rel=\"stylesheet\" type=\"text/css\" href=\"html/contacts.css\"/>"
If you use a css file then you have to use HtmlLoadFile for it to find the css file. I think that the folder path HtmlLoadData is the system default and not the Data folder.
The difference may be that the html browser app has a better default css than the html viewer window provided to developers. If you don't explicitly specify your own css, then you are at the whim of the browser you are using. No two browsers may show the same colors.