FormatterHQ

HTML Table Generator

Create HTML table markup in seconds. Set rows, columns, header, caption, border, padding and width, preview the table and copy clean, indented code.

Output HTML
Ready.

How to use the HTML Table Generator

  1. Enter the number of rows and columns.
  2. Choose whether to include a header row and a caption.
  3. Set border, cell padding, spacing and width, or switch to inline CSS styling.
  4. Generate, check the live preview and copy the table code.

HTML table generator: markup without the typing

Writing <tr> and <td> tags by hand for a 6×10 table is slow and it is easy to drop a cell. This HTML table generator builds the complete structure for you: a <thead> with header cells, a <tbody> with numbered placeholder cells and an optional <caption>. You then replace the placeholder text with your content.

Example: 2 × 2 table with header and caption

<table border="1" cellpadding="5" cellspacing="0" width="100%">
  <caption>Plans</caption>
  <thead>
    <tr>
      <th>Header 1</th>
      <th>Header 2</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Row 1, Cell 1</td>
      <td>Row 1, Cell 2</td>
    </tr>
    <tr>
      <td>Row 2, Cell 1</td>
      <td>Row 2, Cell 2</td>
    </tr>
  </tbody>
</table>

Header cells are labeled "Header 1", "Header 2" and so on, and body cells "Row 1, Cell 1", which makes it easy to find the right cell when you fill in real content.

Attributes or inline CSS?

The generator offers two styling modes:

  • HTML attributes – border, cellpadding, cellspacing and width on the <table> element. They are short and still supported by every browser, and they are the most reliable choice for HTML email, where many clients ignore stylesheets.
  • Inline CSS – border-collapse:collapse and a width on the table, plus a border and padding on every cell. This is the modern, standards-compliant approach; the cellpadding and cellspacing attributes are obsolete in HTML5.

For a website with its own stylesheet, the cleanest option is often to generate the table with border 0, remove the inline styles and style the table, th and td elements in CSS.

Accessible tables

  • Use a header row – <th> cells tell screen readers which label belongs to each data cell.
  • Add a caption – it names the table for all users and is announced first by assistive technology.
  • Use tables for data only – page layout belongs in CSS grid or flexbox, not in tables.

Options

  • Rows 1–100 and columns 1–30.
  • Border width 0–20 px, cell padding 0–50 px, cell spacing 0–50 px.
  • Width as a percentage (100%) or pixels (600).

Already have the data?

If your table content lives in a spreadsheet, skip the placeholders: convert it directly with CSV to HTML or Excel to HTML. For Markdown documents, use the Markdown table generator instead. The table is generated in your browser.

Finishing the generated table

The generator gives you a clean grid. A few small additions turn it into a table that is easier to read and to style:

<th scope="col">Price</th>
...
<tfoot>
  <tr><td>Total</td><td class="num">$120</td></tr>
</tfoot>

tbody tr:nth-child(even) { background: #f6f7f9; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
  • scope="col" on header cells makes the link between headers and data explicit for screen readers.
  • <tfoot> holds totals or notes and belongs after the body.
  • Right-aligned numbers with tabular figures line up digit by digit, which makes columns of prices easy to compare.
  • Zebra stripes via nth-child(even) help the eye follow long rows without adding borders.

Frequently asked questions

Are cellpadding and cellspacing still valid HTML?
They are obsolete in HTML5 but every browser still supports them. Use the inline CSS option, or style the table in your stylesheet, for standards-compliant markup.
How do I merge cells?
Add colspan="2" to a cell to span two columns, or rowspan="2" to span two rows, and delete the cells it replaces. The generator creates a regular grid that you can then adjust.
Which option should I use for HTML email?
Use the HTML attributes option. Many email clients ignore or strip CSS, while border, cellpadding and width attributes are widely supported.
Can I make the table responsive?
Set the width to 100% and wrap the table in a container with overflow-x: auto in your CSS, so wide tables scroll horizontally on small screens.

Last updated September 26, 2026

Related tools

Table to HTML Converter Convert CSV, TSV, Markdown or JSON data into a clean HTML table with optional CSS styling and a live preview. HTML Link Generator Create an HTML anchor tag with link text, title, target _blank, nofollow or sponsored rel and simple inline styling. Favicon Generator Make favicon.ico, Apple touch and Android icons plus site.webmanifest and HTML tags from an image or from text/emoji. ZIP download. Hreflang Tag Generator Generate hreflang annotations for multilingual sites as <link> tags, sitemap entries or HTTP headers, with code validation. .htaccess Redirect Generator Generate Apache .htaccess 301/302 redirects from old → new URL pairs, plus force-HTTPS, www and trailing-slash rules. Hyperlink Generator Generate a hyperlink as HTML, Markdown, BBCode and plain text at once - ready for websites, READMEs, forums and e-mails. HTML to BBCode Converter Convert HTML into forum-friendly BBCode: bold, links, images, lists, quotes, tables, code blocks and inline colours. HTML to Jade Converter Turn HTML into Jade syntax for legacy .jade views, using only markup that also keeps working after an upgrade to Pug. HTML to JSX Converter Convert HTML markup to valid JSX for React: className, htmlFor, style objects, self-closing tags and comments handled automatically. HTML to PHP Converter Convert HTML into PHP echo statements, a string variable or a heredoc block with every quote and dollar sign safely escaped. HTML to Pug Converter Convert HTML to Pug template syntax: indentation-based tags, #id and .class shortcuts, attributes and text blocks. HTML to Text Converter Extract readable plain text from HTML: keeps paragraphs, headings, lists and tables, drops tags, scripts and styles.