How to Generate Clean HTML Table Markup With Headers and Borders in Seconds
Learn how to set rows and columns with sliders, toggle a thead section, basic border CSS and a caption, and copy placeholder table code to fill in.
HTML Table Generator
Introduction
Typing nested table, tr, th and td tags by hand is tedious and a missed closing tag breaks the layout. The HTML Table Generator writes the full skeleton from a row and column count, with an optional header, caption and border styles, so only the cell contents need editing. Generation happens in the browser.
Step-by-Step Instructions
- Drag Number of Rows (1 to 10) to set how many body rows the table has.
- Drag Number of Columns (1 to 6) to set how many cells each row contains.
- Tick Include Table Header to add a thead with a th cell per column, or untick it for a body-only table.
- Tick Include Basic CSS to add a small style block with borders and cell padding, and type a Caption if the table needs a title.
- Review the markup in Generated HTML Table Code and press Copy Code to copy it.
Key Use Cases
- Documentation Tables: Scaffold a three-column spec table and replace the placeholder cells with real values.
- Report Tables: Generate a captioned, bordered table with accessible column headers for a report or admin page.
- Learning HTML: See how thead, tbody, tr, th and td nest correctly for a given grid size.
Frequently Asked Questions
What exactly does the Include Basic CSS option add?
It adds class="data-table" to the table and a style block that sets border-collapse: collapse on the table and a 1px solid #ccc border, 8px padding and left alignment on every th and td. It does not use the obsolete cellpadding or cellspacing attributes. Header cells always get scope="col", and a caption element is added when the Caption field is filled in.
What text goes in the cells?
Header cells are labelled Header 1, Header 2 and so on, and body cells read Row r, Cell c. The tool does not accept custom cell content, so edit the placeholders after pasting the code into an editor.
Is there a limit on table size?
Yes. The sliders allow 1 to 10 rows and 1 to 6 columns, which covers most inline tables. For larger grids, generate the maximum and duplicate rows in the editor, since each row follows the same pattern.