HTML Standard: <table>, <tr>, <td>, <th> tags

<table>, <tr>, <td>, <th> tags

Inserts a table.

Attributes <table>
Attribute Description
align Table alignment: center, left, right.
border A line border for the table.
cellspacing Cell spacing.
class One or more classes.
This attribute used with the wordStyles option allows applying a custom table style.
dir Direction style: ltr, rtl.
id Id.
style Inline styles. Styles can also be applied using style tags.
Attributes <tr>
Attribute Description
class One or more classes.
id Id.
style Inline styles. Styles can also be applied using style tags.
Attributes <td>, <th>
Attribute Description
class One or more classes.
colspan Number of columns for a cell to span.
dir Direction style: ltr, rtl, lrTb, tbRl, btLr, lrTbV, tbRlV, tbLrV.
id Id.
rowspan Number of rows for a cell to span.
style Inline styles. Styles can also be applied using style tags.
Styles <table>
Style Description
background-color
  • hexadecimal color
  • HSL color
  • HSLA color (alpha value is ignored)
  • predefined/cross-browser color
  • RGB color
  • RGBA color (alpha value is ignored)
border, border-top, border-right, border-bottom, border-left border-color:
  • hexadecimal color
  • HSL color
  • HSLA color (alpha value is ignored)
  • predefined/cross-browser color
  • RGB color
  • RGBA color (alpha value is ignored)
border-style:
  • dashed
  • dotted
  • double
  • groove
  • inset
  • none
  • outset
  • ridge
  • solid
border-width:
  • medium
  • thick
  • thin
  • length: cm, in, mm, pt, pc, px
border-collapse
  • collapse
border-spacing
  • length: em, pt, px
direction
  • ltr
  • rtl
display
  • none
float
  • left
  • right
Use with parseFloats option.
margin-left
  • length: em, pt, px
  • percentage
padding-right, padding-left
  • length: em, pt, px
table-layout
  • auto
  • autofit
  • fixed
width
  • length: em, pt, px
  • percentage
Styles <tr>
Style Description
background-color
  • hexadecimal color
  • HSL color
  • HSLA color (alpha value is ignored)
  • predefined/cross-browser color
  • RGB color
  • RGBA color (alpha value is ignored)
border, border-top, border-right, border-bottom, border-left border-color:
  • hexadecimal color
  • HSL color
  • HSLA color (alpha value is ignored)
  • predefined/cross-browser color
  • RGB color
  • RGBA color (alpha value is ignored)
border-style:
  • dashed
  • dotted
  • double
  • groove
  • inset
  • none
  • outset
  • ridge
  • solid
border-width:
  • medium
  • thick
  • thin
  • length: cm, in, mm, pt, pc, px
display
  • table-header-group (to be used in the first tr and also sequential rows)
height
  • length: em, pt, px
page-break-inside
  • avoid
Styles <td>, <th>
Style Description
background-color
  • hexadecimal color
  • HSL color
  • HSLA color (alpha value is ignored)
  • predefined/cross-browser color
  • RGB color
  • RGBA color (alpha value is ignored)
border, border-top, border-right, border-bottom, border-left border-color:
  • hexadecimal color
  • HSL color
  • HSLA color (alpha value is ignored)
  • predefined/cross-browser color
  • RGB color
  • RGBA color (alpha value is ignored)
border-style:
  • dashed
  • dotted
  • double
  • groove
  • inset
  • none
  • outset
  • ridge
  • solid
border-width:
  • medium
  • thick
  • thin
  • length: cm, in, mm, pt, pc, px
direction
  • ltr
  • rtl
  • lrTb
  • tbRl
  • btLr
  • lrTbV
  • tbRlV
  • tbLrV
margin, margin-top, margin-right, margin-bottom, margin-left
  • length: em, pt, px
  • percentage
padding, padding-top, padding-right, padding-bottom, padding-left
  • length: em, pt, px
  • percentage
vertical-align
  • baseline
  • bottom
  • middle
  • sub
  • super
  • text-bottom
  • text-top
  • top
width
  • length: em, pt, px
  • percentage
white-space
  • noWrap
Custom MS Word styles

Using createTableStyle and HTML, custom table styles can be applied to use more styles.

HTML Extended (Premium licenses)
Attribute Description
data-tblpr Applies a custom tblPr style.
data-trpr Applies a custom trPr style.
data-tcpr Applies a custom tcPr style.
CSS Extended (Premium licenses)
Style Description
data-fit-text Text fits the width of the cell:
  • always

MS Word supports up to 63 columns in a table.

MS Word and many other DOCX readers handle automatic sizes in many cases. When adding complex tables with colspans or many columns or using DOCX readers that don't handle automatic sizes correctly (such as Google Docs), it's recommended setting column widths to get a correct output.

Code samples

Example #1

The resulting Word document looks like:

Example #2

The resulting Word document looks like: