Toolvito

Works on this device

HTML Table Generator

Type the cells of a table in rows, or paste CSV text or cells copied from a spreadsheet. You get the HTML source of the table, with a caption and header cells, and CSS if you want it. The page also reads an HTML table and gives its cells back as CSV text.

Your table

For a small table of up to six columns. For a larger table, or for cells that you already have in a file, use the choice with CSV text.

Choices

Optional. A short title that says what the table shows.

Every second row of the body gets a light background.

Rows of the table

Type one row of the table in each row. Use as many of the six columns as you need and leave the others empty. A row with no text is left out.

More options

Optional, for example the Bootstrap classes table table-striped. They are written as typed. No style sheet is linked.

A CSS colour such as #1f4e79 or navy. The text of the header row becomes white or black, whichever is easier to read on it.

Your values are worked out in this browser. They are not sent to a server.

Your result will show here

Fill in the boxes, or choose Try an example. Then choose the button below the boxes.

How to make a table

  1. Choose what you want to do. Make a table from cells typed in rows is for a small table. Make a table from CSV text or from cells copied from a spreadsheet is for a table that you already have.
  2. Type the cells, or paste the text. Try an example fills the boxes with a small made-up table.
  3. Type a caption, and say if the first row or the first column holds headers.
  4. Choose the CSS: rules for a style sheet, style attributes on every cell, or no CSS. More options has class names, the colour of the header row, the lines, the space inside a cell and the indent of the source.
  5. Choose Make the table. Copy the HTML or download it. Download the whole page and open it in your browser to see the table.

What you get

  • HTML of the table: the table element with its caption, header cells and data cells. Put it into your own page.
  • CSS for the table: plain CSS rules for the style sheet of your page. This box is shown when you choose CSS rules, and when a table with no CSS stands in a scrolling box, which needs one rule.
  • Whole page to open in a browser: a small page with the table and its CSS. Download it and open the file to see the real table.
  • A list of numbers: rows, columns, header cells, data cells and empty cells, and the contrast of the text when you choose CSS.

How the table is written

  • The caption is written as a caption element, the first thing inside the table.
  • The header row stands in thead, and each of its cells is <th scope="col">. All other rows stand in tbody.
  • With a header column, the first cell of each row of the body is <th scope="row">.
  • With a header row and a header column, the top left cell is a plain td when it is empty.
  • An empty cell stays a cell. In CSV text, a row with fewer cells than the widest row gets empty cells at its end.
  • A line break inside a cell of CSV text is written as <br>.
  • The characters &, < and > are written as &amp;, &lt; and &gt;, so text that you type cannot become HTML.

The CSS

  • With CSS rules for a style sheet, the rules use the first class name that you typed. If you typed none, the class data-table is added to the table.
  • With Style attributes on every cell, each element carries its styles in a style attribute and no style sheet is needed. This form is for an email, because many mail programs do not follow a style sheet.
  • The text is #1a1a1a on a white background, #ffffff. With striped rows, every second row of the body is #f2f5f8. The contrast of the text is 17.40 to 1 on white and 15.91 to 1 on a striped row.
  • You choose the background colour of the header row. Its text becomes white or black, whichever has the higher contrast. One of the two always has a contrast of at least 4.5 to 1, the level that WCAG 2 asks for text of normal size.
  • Where the text stands in a cell writes vertical-align: top, vertical-align: middle or vertical-align: bottom for every cell. When nothing is set, browsers put the text in the middle of a cell.
  • The lines are 1 pixel wide in #6b7785. The text of every cell starts at the left (text-align: left).
  • For Bootstrap or another framework, type its class names, for example table table-striped, and choose no CSS. The names are written as typed. This page does not link the style sheet of a framework: your own page must load it.

A table for a small screen

  • Tick Put the table in a box that scrolls sideways on a small screen. The table is then written inside <div class="table-scroll" role="region" aria-label="..." tabindex="0">.
  • The box needs one CSS rule: overflow-x: auto. On a narrow screen the box scrolls sideways, and the page does not. With style attributes, the box has no class and carries this rule in its own style attribute.
  • The box takes its name from the caption, or from the name that you type. A screen reader says this name. tabindex="0" lets a keyboard user move to the box and scroll it with the arrow keys.

CSV text and cells from a spreadsheet

  • Each line is one row. A comma, a semicolon or a tab stands between two cells. Find it for me looks at the first line: a tab wins; else the semicolon wins when the line has more semicolons than commas; else it is a comma.
  • Cells copied from Excel, Google Sheets or another spreadsheet have tabs between them. Copy the cells, paste them into the box, and make the table.
  • A cell may stand in quotation marks. Inside them a comma and a line break are part of the cell, and two quotation marks stand for one: "Mug, ""large""" is the cell Mug, "large".
  • Text after the closing quotation mark of a cell is an error, and so is a quotation mark that is never closed. The message names the line.
  • A quotation mark that is not the first character of a cell is an ordinary character, as in 5" pipe.
  • Spaces at the two ends of a cell are removed, but not in a cell in quotation marks. You can turn this off under More options.
  • An empty line is left out. The page takes at most 2,000 rows, 100 columns and 50,000 cells.

Read an HTML table

  • Paste the HTML of a table or of a whole page. If it has more than one table, a list shows them, and you type the number of the table to read.
  • You get the cells as a table to look at and as CSV text. A button moves them into the boxes of this page, so that you can change them and make the table again. A table of up to 6 columns and 100 rows goes into the typed rows, and a larger one goes into the box for CSV text.
  • A cell with colspan or rowspan takes more than one place. You choose the rule: its text goes into the first place and the other places stay empty, or its text is repeated in every place.
  • The rows of thead come first and the rows of tfoot come last, as a browser shows them. If a table has a second thead or tfoot, its rows stay where they stand in the source.
  • A table inside a cell is a table of its own, with its own number. In the outer table its text is part of that cell.
  • End tags that are left out are put back by the common rules: a new row ends the open row, and a new cell ends the open cell.
  • Parts that the HTML hides are left out. You can turn this off under More options.
  • In the text result, a cell that starts with =, +, -, @ or a tab and is not a plain number gets an apostrophe in front, because a spreadsheet could run such a cell as a formula. A number with a sign, such as -5 or +0.25, is left as it is. You can turn this off under More options.

Worked example

Choose Make a table from cells typed in rows and then Try an example. The rows are: Plan, Price for one month, Storage; then Basic, 5 USD, 10 GB; then Plus, 9 USD, 50 GB; then Team, 19 USD, 200 GB. The caption is "Plans and prices".

The result has 4 rows and 3 columns, with 3 header cells and 9 data cells. The HTML starts with <table class="data-table"> and <caption>Plans and prices</caption>, and the first header cell is <th scope="col">Plan</th>. The header row has white text on #1f4e79, with a contrast of 8.66 to 1.

Now choose Read an HTML table and Try an example. The last row of that table is <tr><td>Sunday</td><td colspan="2">Closed</td></tr>. In the CSV text it becomes Sunday,Closed, with an empty last cell. With the other rule it becomes Sunday,Closed,Closed.

Limits you should know

  • There is no picture of the table on this page. The page never puts HTML that you make or paste into itself, and it runs and loads nothing from it. The downloaded page shows the real table in your own browser.
  • The typed rows take up to 6 columns and 100 rows. Use CSV text for a larger table.
  • The generator writes one header row and one header column. It does not write merged cells (colspan and rowspan), a table inside a table, images or links in cells, or a table made of div elements. A cell holds text only.
  • The CSS is small and has fixed colours for the text, the lines and the striped rows. Change it in your own style sheet when you need more.
  • Mail programs draw HTML in their own ways. Send yourself a test email before you use a table in an email.
  • The reader follows the HTML source and its style attributes only. It does not read style sheets and does not run scripts, so a table that a script builds in the browser is not in the source and cannot be read.
  • The CSV text is UTF-8 with no byte order mark, and its rows end with CR LF.
  • This page gives no program code, such as JavaScript or SQL, that builds a table.

Related tools