Word .NET > Tutorial > Import HTML document to Word

The following example shows you how to import an HTML document into a Word document. The LoadFromHtml method converts HTML elements to Word format, preserving text formatting, tables, hyperlinks, and other elements.

C# example - Load from HTML file
C# example - Load from HTML string
VB example

HTML elements supported:

  • Headings (h1-h6) with automatic formatting
  • Paragraphs (p, div) with alignment and spacing
  • Text formatting (b, strong, i, em, u, s, strike, del)
  • Font tags with color, face, and size attributes
  • Span elements with inline CSS styles
  • Superscript (sup) and subscript (sub)
  • Tables (table, tr, td, th) with styling
  • Lists (ul, ol, li) converted to numbered/bulleted lists
  • Hyperlinks (a) with href and title attributes
  • Line breaks (br)
  • Images (img) as placeholders

CSS properties supported:

  • text-align (left, center, right, justify)
  • color (hex, rgb, named colors)
  • background-color (hex, rgb, named colors)
  • font-family, font-size, font-weight, font-style
  • text-decoration (underline, line-through)
  • margin-left, margin-right, margin-top, margin-bottom
  • text-indent
  • vertical-align (top, middle, bottom, super, sub)

Need help? Ask our developers: