Html to OpenXmlHtml to OpenXml
Home
API Reference
LLM Docs Friendly
NuGet
GitHub
Home
API Reference
LLM Docs Friendly
NuGet
  • API Reference

    • Quickstart
    • Library Entry Points
    • Hyperlinks and Internal Navigation
    • Image and Asset Processing Guide
    • Styling
    • Tables
    • Numbering List
    • Preformated Text
    • Defined Terms and Notes
    • Page Layout
    • Right to Left (Rtl)
  • LLM Docs Friendly
  • Performance
  • Appendix

    • Content Type MIME Header
    • Convert .dotx to .docx
    • Placeholder Replacement
    • Restrict Editing
  • Changelog

Styles

Styles defined in the <table> tag are applied inside the table’s elements. Defined width attributes in table is applied in the open xml document. No border attribute or a border="0" will hide the border on the word document.

Table Widths

Those width are supported:

HTML AttributeConverter ActionMeaning in DOCX
autoAuto-Fit ContentDynamically adjusts column widths to fit content.
100% or (no width)Page-Width DefaultSpan the full printable page width.
[value]%Percentage WidthApplies a percentage of the available page width.
px or ptFixed DimensionLocks the column/cell to a specific physical size.

Disclaimer: The output DOCX file is fully compliant with Open XML. Compatibility with third-party viewers (e.g., MacOS Pages) may vary when rendering complex structural elements like merged cells.

Row Span and Column Span

<table width="50%" align="center" border="1">
    <tr>
        <td rowspan="2">Row Header</td>
        <td>Row 1</td>
    </tr>
    <tr>
        <td>Row 2</td>
    </tr>
</table>

Table with row span

<table width="100%" border="1">
    <tr>
        <td>Header 1</td>
        <td colspan="2">Header 2</td>
    </tr>
    <tr>
        <td>Cell 1.1</td>
        <td>cell 1.2</td>
        <td>cell 1.3</td>
    </tr>
</table>

Table with col span

ColSpan and RowSpan on the same cell

<table border="1">
    <tr>
        <th>Cell 1</th>
        <th colspan="2" rowspan="2">Value 1</th>
    </tr>
    <tr>
        <td>Cell 1</td>
    </tr>
    <tr>
        <td>Cell 2</td>
        <td>Value 2</td>
        <td>Value 3</td>
    </tr>
</table>

Table with a cell containing both row span and col span

Nested table

<table width="100%" border="1">
<tr>
    <td><b>Parent table</b>
        <table border="1">
            <tr>
                <td>Nested table</td>
            </tr>
        </table>
    </td>
</tr>
</table>

Nested table

Vertical text is supported

<table width="50%" align="center" border="1">
    <tr>
        <td rowspan="2" style="writing-mode: tb-lr;">Vertical Row Header</td>
        <td>Row 1</td>
    </tr>
    <tr>
        <td>Row 2</td>
    </tr>
</table>

Table with vertical text

Column Definition

col tag describing the styles of columns across the whole table. You may or may not place those tags inside a colgroup tag.

The attribute span is supported to copy the styles on the next columns.

<table>
<col />
<col style='text-align:center' span='2' />
<tr>
    <td>Cell 1.1</td><td>Cell 1.2</td><td>Cell 1.3</td>
</tr>
</table>

Table colgroup

Logical Table Sections

Unlike the flexibility of HTML parsers, the converter enforces the logical flow required by Open XML. Therefore, regardless of the order in which you input the <thead>, <tbody>, and <tfoot> tags, they will always be correctly ordered in the final document body (Header → Body → Footer).

<table>
    <tbody><tr><td>Body</td></tr><tbody>
    <thead><tr><td>Header</td></tr><thead>
    <tfoot><tr><td>Footer</td></tr><tfoot>
</table>

Reordered table sections

Edit this page
Last Updated: 10/12/26, 10:33 AM
Contributors: Olivier Nizet
Prev
Styling
Next
Numbering List