About the HTML Table Generator
Tables for pricing, schedules and specifications look professional when the markup is clean and accessible. This HTML table generator lets you type data into an editable grid or paste it from a spreadsheet, add a caption and header row, choose borders, striped rows and alignment, and copy ready-to-use HTML and CSS. Cells are escaped safely, and the header uses proper table semantics for screen readers. A live preview shows the finished table as you edit, so you can adjust styles before copying the code. To convert an existing CSV file directly, use CSV to HTML Table.
Style the table with simple controls: borders around every cell or only between rows, cell padding, header background, alternating row stripes and full-width layout. Choose inline styles when the table must look right anywhere, such as in an email or a CMS that strips stylesheets, or a class with a separate CSS block for cleaner markup on your own site.
Set the alignment of each column, mark the first column as row headers, and the generator adds scope attributes so screen readers announce the right headers. The live preview renders the exact code in an isolated frame, so what you see is what you will paste. Copy the HTML and the CSS, or download a complete page.
To convert an existing CSV file, use the CSV to HTML table converter. For documentation tables, try the Markdown table generator, and to tidy any markup, the HTML formatter.
How to use the HTML Table Generator
- Enter the dataType into the grid, or paste cells from a spreadsheet or CSV and press Import.
- Set the structureAdd a caption, and choose the header row, header column and column alignment.
- Style itPick inline styles or a CSS class, then set borders, padding, colors and stripes.
- Copy the codeCheck the preview, then copy the HTML and CSS or download the page.
HTML Table Generator features
- Editable grid with rows and columns
- Paste from Excel, Google Sheets or CSV
- Caption, header row and header column
- Inline styles, CSS class or no styling
- Borders, padding, header color and stripes
- Per-column alignment
- Accessible scope attributes
- Live isolated preview and page download
Common uses
- Adding styled tables to emails and newsletters
- Building pricing and comparison tables
- Creating tables for CMS pages that strip CSS
- Prototyping data layouts
- Learning HTML table structure
HTML tables in practice: a class timetable, tables in emails, layout versus data tables, column widths and right-to-left Urdu tables
Hand-built HTML tables are still needed in many places: a timetable on a school site, a comparison in an email newsletter, a schedule in a content management system that strips stylesheets. This guide builds a timetable with row headers, explains what changes when a table goes into an email, and covers layout tables, column widths, complex headers, hover highlighting and Urdu tables that read from right to left.
A worked example: a class timetable
A tuition centre in Rawalpindi publishes a weekly timetable with days across the top and time slots down the side. In the generator, the first row holds the days and the first column holds the times, marked as row headers. The output places the days in a thead section with column scope and gives each time cell row scope, so a screen reader announces, for example, Wednesday, 5 pm, Chemistry. A caption such as Weekly timetable, winter term 2026 tells everyone what the table shows.
Tables in emails
Email clients support far less CSS than browsers. Some ignore style blocks, and desktop Outlook renders emails with Word's engine, which ignores many modern properties. Inline styles on each cell, widths set as attributes as well as styles, and simple borders give the most consistent result across clients. Always send a test to Gmail, Outlook and a phone before mailing a list.
Layout tables and data tables
On websites, tables should hold data, not arrange page layout, which is the job of CSS grid and flexbox. In emails, layout tables remain normal because many clients lack modern CSS. Marking those with role="presentation" tells screen readers to ignore the table structure, while real data tables keep their headers and captions.
Column widths
By default, browsers size columns by their content, so one long word can squash every other column. Setting table-layout: fixed; with explicit widths gives predictable columns, and overflow-wrap: anywhere; lets long items such as email addresses or URLs wrap instead of overflowing. This is especially useful for tables viewed on phones.
Complex headers
Tables with two levels of headers, such as subjects grouped under morning and evening sessions, need more than scope attributes for screen readers to announce them correctly; each data cell must reference its headers by ID. Where possible, splitting a complex table into two simpler ones is easier for everyone to read and far easier to maintain.
Highlighting rows
On wide tables, a subtle highlight on the row under the cursor, using a rule such as tbody tr:hover { background: #f3f6fb; }, helps readers follow a row across many columns. Keep the highlight colour light enough that text contrast stays comfortable.
Urdu tables
Adding dir="rtl" to a table containing Urdu content flips the column order, so the first column appears on the right as Urdu readers expect, and text aligns to the right. A lang attribute set to ur helps browsers choose suitable fonts and lets screen readers pronounce the text correctly. Numbers inside Urdu tables still read left to right within each cell.
Pasting into a content management system
Some editors strip attributes and styles from pasted HTML. In WordPress, a Custom HTML block keeps the code intact. If a system strips class names, inline styles are the fallback; if it strips everything, a simpler table without styling is better than a broken one.
Common mistakes
- Using tables for website layout.
- Relying on style blocks in email tables.
- Letting long words break column widths on phones.
- Building multi-level header tables when two simple tables would do.
Related tools
To shrink the generated code, use HTML Minifier. To check header and stripe colours stay readable, try Color Contrast Checker, and to escape special characters in content, HTML Encoder & Decoder.
Totals in a footer
A row of totals belongs in a tfoot section, which tells browsers and assistive technology that it summarises the data above. Styling it with a top border or bold text separates it visually from ordinary rows. When the table is printed across several pages, keeping totals in their own section makes them easy to find at the end.
Empty cells
A blank cell is ambiguous: it might mean zero, not applicable or unknown. Writing a dash, None or N/A, and explaining the meaning in a note below the table if needed, removes the doubt. Screen readers may also skip empty cells silently, which can confuse listeners following a row.
Dark mode in emails
Some email apps automatically change colours in dark mode, turning light backgrounds dark and adjusting text colours. Tables with fixed inline colours can end up with poor contrast or odd patches of colour. Testing the email in dark mode on a phone, and avoiding very pale text on very light backgrounds, keeps tables readable for everyone.
Sorting by column
A small script can make a static table sortable by clicking its headers, which helps readers of long price lists and directories. Put a button inside each sortable header and update the aria-sort attribute when the order changes, so keyboard and screen reader users can sort the table as easily as mouse users.
Privacy
Tables are generated in your browser. Your data is not uploaded or stored.
Frequently asked questions
Should I use inline styles or a CSS class?
Use inline styles for emails and for editors that remove stylesheets, because every cell then carries its own styling. Use a class on your own website: the markup stays clean and you can change the look of every table from one stylesheet.
How do I paste data from a spreadsheet?
Copy the cells in Excel or Google Sheets and paste them into any grid cell. The data fills the grid from that cell and adds rows and columns as needed. You can also paste CSV into the import box and press Import.
What are thead, tbody and caption for?
The thead section holds the header row, tbody holds the data rows and caption gives the table a visible title. They help screen readers and search engines understand the table, and they make styling easier.
What is a header column?
When the first column labels each row, for example plan names or days of the week, its cells become row headers with the scope attribute set to row. Screen readers then announce that label together with each value in the row.
Will the table work on mobile?
Wide tables can overflow small screens. Wrap the table in a container whose overflow-x is set to auto so it can scroll sideways, or keep the number of columns small for mobile visitors.
Is the cell content escaped?
Yes. Characters such as <, > and & are converted to HTML entities, so the text appears exactly as typed and cannot break your page or inject code into it.
Is anything uploaded?
No. The grid, the styling and the code generation all run in this page on your own device. Nothing is sent to a server or stored, so you can use it with private data.
Can I import an existing table?
Yes. Paste CSV, cells copied from a spreadsheet or a Markdown table into the import box and press Import. The data fills the grid, and Markdown column alignment is kept, so you can restyle the table as HTML.