Tables
Stay organized with collections
Save and categorize content based on your preferences.
In many contexts, tables are the best way to represent sets of related pieces of data. However,
in some contexts, other approaches are better choices.
List or table?
Tables and lists are both ways to present a set of similarly structured
items; sometimes it's not obvious when to choose one presentation over the
other. To decide which presentation to use, consult the following table:
Item type |
Example |
How to present |
Each item is a single unit. |
A list of programming language names, or a list of steps to follow. |
Use a numbered list, lettered list, or bulleted
list. |
Each item is a pair of pieces of related data. |
A list of term/definition pairs. |
Use a description list (or, in some
contexts, a table). |
Each item is three or more pieces of related data. |
A set of parameters, where each parameter has a name, a data type, and a
description. |
Use a table. |
Places not to use tables
- Don't use tables to lay out a page; use your site's standard CSS instead.
- Usually if you have only one row of material, a table isn't the best
choice for how to present it. But in some contexts (especially for consistency
of layout in reference documentation), it might be.
- If you have only one column in your table, turn the table into a list.
- Don't use tables to lay out code snippets.
- Don't use tables to lay out long one-dimensional lists in multiple
columns. For example, if you have a long list of function names, don't try to
save space by splitting the list in half and presenting the two halves as a
two-column table. Use tables only to present two-dimensional data—that is,
material that semantically makes sense to display in rows and columns.
- Avoid tables in the middle of a numbered procedure.
Multi-paragraph table cells
Any table cell can contain more than one paragraph.
To create multiple paragraphs, use the p
element rather
than using the br
element. (The HTML specification
describes which uses of the br
element are legitimate and which aren't.)
Example of a table with some cells that contain more than one paragraph:
Attribute name |
Type |
Description |
href |
HTML |
Defines the URL for a link.
For example, go to the
<a href="https://www.google.com">Google Search</a> page. |
src |
HTML |
Defines the path of the image to be displayed.
For example, <img src="kitten.jpg"> . |
Introductory sentences for tables
Introduce tables with a complete sentence that describes the purpose of the table because not all
screen readers preannounce tables. The introductory sentence can end with a colon or a period;
usually a colon if it immediately precedes the table, and usually a period if there's more material
(such as a note paragraph) between the introduction and the table.
Recommended: Change the environment variables
to values for your deployment, as listed in the following table:
For more information, see the
Tables section of the "Accessibility" page.
Table placement
- When introducing a table, use a complete sentence and try to refer to the
table's position, using a phrase like the following table or the preceding table.
- Don't put a table in the middle of a sentence.
- Avoid using footnotes when possible. If your table does refer to footnotes, place them
immediately following the table. For more information, see
Footnotes.
Table captions
If your document contains only one table, the table doesn't need a caption.
However, be sure to place the table adjacent to the text that refers to it.
If your document contains more than one table in fairly close proximity to
each other, include a caption for each one, using a caption
element as the first child of the table
element. Start the
caption with a number, in the form "<b>Table NUMBER.</b>
DESCRIPTION". Use sentence case for the caption, but don't place a
period at the end.
When referring to the table from text, refer to it by its number—for example,
... as shown in table 2. Do not capitalize table unless it starts a sentence.
Your site's CSS determines the styling and placement of the caption.
Recommended:
<table>
<caption><b>Table 1.</b> Prehistoric birds</caption>
...
</table>
Table column heads
- Use sentence case.
- Write concise headings.
- Don't end with punctuation, including a period, an ellipsis, or a colon.
- Use table headings for the first column and the first row only. Use the
th
element.
- Include the
scope
attribute as appropriate for accessibility.
Responsive tables
Where possible, use table CSS that adapts to different viewport sizes.
Link to tables
Where possible, avoid linking to tables; instead, refer to them by table number.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-03-21 UTC.
[null,null,["Last updated 2025-03-21 UTC."],[[["\u003cp\u003eTables are ideal for presenting data with three or more related pieces of information per item, while lists are better for simpler data structures.\u003c/p\u003e\n"],["\u003cp\u003eWhen using tables, introduce them with a complete sentence, use clear and concise column headings, and avoid unnecessary styling or formatting.\u003c/p\u003e\n"],["\u003cp\u003eEnsure table accessibility by using proper HTML elements like \u003ccode\u003ecaption\u003c/code\u003e, \u003ccode\u003eth\u003c/code\u003e, and \u003ccode\u003escope\u003c/code\u003e, and provide descriptive alternative text for any images or symbols.\u003c/p\u003e\n"],["\u003cp\u003eFor single-unit items, use bulleted, lettered, or numbered lists; for paired data, consider description lists or tables depending on the context.\u003c/p\u003e\n"],["\u003cp\u003eAvoid using tables for page layout, code snippets, long one-dimensional lists, or within numbered procedures, and ensure responsiveness for various viewport sizes.\u003c/p\u003e\n"]]],["When choosing between tables and lists, use lists for single units or pairs of data, and tables for three or more related data pieces. Avoid tables for page layout, single rows/columns, code snippets, or long one-dimensional lists. Introduce tables with a descriptive sentence, and position them appropriately. Number and caption multiple tables, using sentence case. Use `th` elements for headers, avoiding visual styling, cell merging, and images alone to convey information. Format for different viewport sizes and avoid linking to tables.\n"],null,["# Tables\n\nIn many contexts, tables are the best way to represent sets of related pieces of data. However,\nin some contexts, other approaches are better choices.\n\nList or table?\n--------------\n\nTables and lists are both ways to present a set of similarly structured\nitems; sometimes it's not obvious when to choose one presentation over the\nother. To decide which presentation to use, consult the following table:\n\n| Item type | Example | How to present |\n|----------------------------------------------------|---------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------|\n| Each item is a single unit. | A list of programming language names, or a list of steps to follow. | Use a [numbered list, lettered list, or bulleted list](/style/lists#numbered-lettered-bulleted-lists). |\n| Each item is a pair of pieces of related data. | A list of term/definition pairs. | Use a [description list](/style/lists#description-lists) (or, in some contexts, a table). |\n| Each item is three or more pieces of related data. | A set of parameters, where each parameter has a name, a data type, and a description. | Use a table. |\n\n### Places not to use tables\n\n- Don't use tables to lay out a page; use your site's standard CSS instead.\n- Usually if you have only one row of material, a table isn't the best choice for how to present it. But in some contexts (especially for consistency of layout in reference documentation), it might be.\n- If you have only one column in your table, turn the table into a list.\n- Don't use tables to lay out code snippets.\n- Don't use tables to lay out long one-dimensional lists in multiple columns. For example, if you have a long list of function names, don't try to save space by splitting the list in half and presenting the two halves as a two-column table. Use tables only to present two-dimensional data---that is, material that semantically makes sense to display in rows and columns.\n- Avoid tables in the middle of a numbered procedure.\n\nMulti-paragraph table cells\n---------------------------\n\nAny table cell can contain more than one paragraph.\n\nTo create multiple paragraphs, use the `p` element rather\nthan using the `br` element. (The HTML specification\ndescribes which uses of the [`br`\nelement](https://html.spec.whatwg.org/multipage/semantics.html#the-br-element) are legitimate and which aren't.)\n\nExample of a table with some cells that contain more than one paragraph:\n\n| Attribute name | Type | Description |\n|----------------|------|---------------------------------------------------------------------------------------------------------------|\n| `href` | HTML | Defines the URL for a link. For example, go to the `\u003ca href=\"https://www.google.com\"\u003eGoogle Search\u003c/a\u003e` page. |\n| `src` | HTML | Defines the path of the image to be displayed. For example, `\u003cimg src=\"kitten.jpg\"\u003e`. |\n\nIntroductory sentences for tables\n---------------------------------\n\nIntroduce tables with a complete sentence that describes the purpose of the table because not all\nscreen readers preannounce tables. The introductory sentence can end with a colon or a period;\nusually a colon if it immediately precedes the table, and usually a period if there's more material\n(such as a note paragraph) between the introduction and the table.\n\nRecommended: Change the environment variables\nto values for your deployment, as listed in the following table:\n\nFor more information, see the\n[Tables](/style/accessibility#tables) section of the \"Accessibility\" page.\n\nTable placement\n---------------\n\n- When introducing a table, use a complete sentence and try to refer to the table's position, using a phrase like *the following table* or *the preceding table*.\n- Don't put a table in the middle of a sentence.\n- Avoid using footnotes when possible. If your table does refer to footnotes, place them immediately following the table. For more information, see [Footnotes](/style/footnotes).\n\nTable captions\n--------------\n\nIf your document contains only one table, the table doesn't need a caption.\nHowever, be sure to place the table adjacent to the text that refers to it.\n\nIf your document contains more than one table in fairly close proximity to\neach other, include a caption for each one, using a [`caption`\nelement](https://html.spec.whatwg.org/multipage/tables.html#the-caption-element) as the first child of the `table` element. Start the\ncaption with a number, in the form \"\\\u003cb\\\u003eTable \u003cvar translate=\"no\"\u003eNUMBER\u003c/var\u003e.\\\u003c/b\\\u003e\n\u003cvar translate=\"no\"\u003eDESCRIPTION\u003c/var\u003e\". Use sentence case for the caption, but don't place a\nperiod at the end.\n\nWhen referring to the table from text, refer to it by its number---for example,\n*... as shown in table 2* . Do not capitalize *table* unless it starts a sentence.\n\nYour site's CSS determines the styling and placement of the caption. \nRecommended: \n\n```\n\u003ctable\u003e\n \u003ccaption\u003e\u003cb\u003eTable 1.\u003c/b\u003e Prehistoric birds\u003c/caption\u003e\n ...\n\u003c/table\u003e\n```\n\nTable formatting\n----------------\n\n- Don't add styling to the table element.\n- Don't apply a visual style such as a different font, font color, or background color to convey a header row or column by itself. Use the `th` element to semantically mark up headers in tables.\n- Don't merge cells. Don't use `colspan` or `rowspan` attributes.\n- Sort rows in a logical order, or alphabetically if there is no logical order.\n- If the table is long or complicated---for example, with multiple header rows or columns---consider splitting it into multiple tables.\n- Don't present new information in tables through images or symbols alone; always provide a descriptive `alt` attribute for the image or symbol. For more information, see [Alt text](/style/images#alt-text).\n\nTable column heads\n------------------\n\n- Use sentence case.\n- Write concise headings.\n- Don't end with punctuation, including a period, an ellipsis, or a colon.\n- Use table headings for the first column and the first row only. Use the [`th` element](https://www.w3.org/TR/2014/REC-html5-20141028/tabular-data.html#the-th-element).\n- Include the [`scope` attribute](https://www.w3.org/TR/WCAG20-TECHS/H63.html) as appropriate for accessibility.\n\nResponsive tables\n-----------------\n\nWhere possible, use table CSS that adapts to different viewport sizes.\n\nLink to tables\n--------------\n\nWhere possible, avoid linking to tables; instead, refer to them by table number."]]