To me the second method was problematic. After searching, I found an apparently equally good solution:
webBrowser1.DocumentText = text;
or in your case:
webBrowser1.Document.Write("<h1>Hello, world!</h1>");
from here: http://www.windowsdevelop.com/windows-forms-general/webbrowser-stealing-focus-56881.shtml[^].