GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing en.wikipedia.org — Help:Advanced table features - Wikipedia
Tables can be used as formatting instrument, but consider using a multi column list instead. Horizontal alignment in cellsBy default, text is aligned to the left of data cells. By default, text is aligned to the center of header cells. All of the above is true in both desktop and mobile view. The alignment of header text in tables with Header text alignment in tables without class=wikitable follows the global text alignment of the table. Text alignment set in individual cells overrides everything else. Aligning text in header cells versus other cellsNote: For vertical alignment of text see: Help:Table#Vertical alignment in cells. If there is no global text alignment set in the top line of the table wikitext, then all text is left aligned, except for header cells which are default center aligned. Only in tables with When using Aligning the data in data columns to the rightBoth tables below use
If most columns consist of data cells, then you might choose to align the data to the right. It is easy.
or
and so on. Decimal point alignmentTo align unlike decimals in a column, use Template:0 to pad one side with invisible zero characters, depending on the alignment. Wikitext {| class="wikitable" style="text-align: right;" ! Heading |- | 432.1{{0|00}} |- | 43.21{{0|0}} |- | 4.321 |} Rendered result
Column alignment{{Table alignment}} can be used to align the cells in a whole column without adding code to each cell. For example, to left align the first column, center align the fourth column, and default align all other cells to the right:
Place
The "col" classes never affect the header cells. The "default" classes also affect the header cells if wikitable class is not used. With the wikitable class header cell content is always centered unless individually adjusted. See template for more info, limitations, examples. Aligning the text in the first column to the leftTemplate:Table alignment (see previous section) will not work on columns of row headers. There are some other limitations listed at Template:Table alignment. In these cases you can try the following method for the first column only. This can be done in the wikitext source editor. In editing preferences check the box labeled: "enable the editing toolbar. This is sometimes called the '2010 wikitext editor'." In the table section click "edit source" (wikitext editing). Click on "Advanced" in the editing toolbar. Then click on the "search and replace" icon on the right. In the popup form check the box for "Treat search string as a regular expression". Fill in the "Search for" box with
Then click "Replace all". All the text in the first column will be aligned to the left of their cells. If for some reason those cells are header cells, then fill in the "Search for" box with
Note the exclamation point for a header cell. Fill in the "replace with" box with
Then click "Replace all". Side-by-side tablesSee also: Template:Column-generating template families for other options.
This method wraps two or more blocks side by side in rows on wide screens, and unwraps responsively on narrow screens by stacking them vertically. These blocks can contain a table or other elements. Example using Template:Flexbox wrap. Aligned to the top. It adds a 1em gap between blocks. The Wikitext {{Flexbox wrap|start|flex=none}} <!-- First table --> {{Flexbox wrap|break|flex=none}} <!-- Second table --> {{Flexbox wrap|end}} Produces
Example on a table and image.
To wrap long text, add the Example on two layout tables, each with a description and image. Each table uses
Note: Do not use Note: Blocks are separated by a gap. Avoid adding Side-by-side tables with single description
Example of a description and three tables nested in a layout table. These nested tables wrap on wide screens and vertically stack on narrow screens. For screen readers, each nested table has a caption that uses {{Screen reader-only}} to visually hide them in favor of the description, and still allow screen readers to read those captions. Note the Adapted from a version of Wealth inequality in the United States#Statistics.
{{Mw-datatable}}{{Table alignment}} {| class="wikitable" role="none" | '''Note US wealth concentration (<span style="background-color: #9EFF9E; color: black;">green</span>) 1989 Q3 to 2026 Q2.''' |- | {{Flexbox wrap|start|flex=none}} {| class="wikitable mw-datatable defaultright col1left" style="margin: 0;" |+ {{Screen reader-only|Wealth percentile band from 1989 Q3 to 2026 Q2}} ... |} {{Flexbox wrap|break|flex=none}} <!-- Second nested table --> {{Flexbox wrap|break|flex=none}} <!-- Third nested table --> {{Flexbox wrap|end}} |} Scrolling tablesA whole table can be placed within a scrolling div so that new table lines appear on the screen as old table lines disappear. See MOS:SCROLL, and Help:Scrolling list, and this article discussion. Vertical scrolling table
<div style="height:7em; overflow:auto; border:2px solid red;"> {| class=wikitable |- | abc || def || ghi |- style="height: 100px;" | jkl || style="width: 100px;" | mno || pqr |- | stu || vwx || yz |} </div> Horizontal scrolling tableSee also: Help:Table § Overflowing tables
Adding
<div style="width:12em; overflow-x:auto; border:2px solid lime;"> {| class=wikitable style="width:25em" |- | abc || def || ghi |- | jkl || style="height: 70px;" | mno || pqr |- | stu || vwx || yz |} </div> Tables with sticky headers
Template:Sticky header creates a sticky scrolling table in the sense of the vertical scrollbar for the whole page. When you scroll the page the table headers stay visible when the table goes beyond the top of the screen. See also: Template:Sticky table start. It has an option for side sticky headers too. It puts the table in a scrollbox, and the scrollbars are part of that box. See {{Sticky header}} examples below:
See list of articles transcluding Scrolling tables with sticky column and row headersNote: Sticky left-side row headers do not work correctly if table is inside a collapsible show/hide box. See example. ("Timeshifter table" section) See: Template:Sticky table start. It incorporates the old Covid CSS, and it is easier to use. See Special:WhatLinksHere/Template:Sticky table start for examples. There are several advanced scrolling tables (with row and column headers that stay visible and sticky while scrolling) in COVID-19 pandemic by country and territory and in COVID-19 pandemic deaths. The scrolling and sticky headers work in cell phones, too. Widest scrolling tables are on top of the list below. Narrow your browser window until you see a horizontal scroll bar. Drag it left and right to see the sticky row headers that stay visible.
A totally blind screen reader user noted in a discussion here that the scrolling tables in the related article (COVID-19 pandemic deaths) were not a problem. Automatically updated scrolling tables with sticky headersThese scrolling tables linked below with top/side sticky headers are also automatically updated. Narrow browser window to see sticky headers on the side.
See discussion: Transclude a table from another pageA table can be put in a template. For example, see this list of life expectancy table template subpages. You can search for template subpages:
{{Excerpt}} is the simplest tool for transcluding a table that is not in a template. Go there for many options. The simplest method: {{Excerpt|Page source of table|Section with the table|this=This table is}} It transcludes the table to wherever it is placed. It adds the following indented note above it in italics. The page section is linked, and there is an edit link for the source page:
A hidden note
A hidden note at the source section is helpful too. Such as:
All broken excerpts are automatically tracked at Category:Articles with broken excerpts and regularly fixed. Sortable tables
Main pages: Help:Sortable tables and mw:Help:Sortable tables
See Help:Sortable tables for details of how to make sortable tables. Tables can be made sortable by adding Collapsible tablesSee also: Help:Collapsing § Collapsible tables
Classes can also be used to collapse tables, so they are hidden by default. Use the class Note: Previous versions of this article recommended the Example with a header row Wikitext {| class="wikitable mw-collapsible mw-collapsed" |- ! Header |- | Content that starts hidden |- | More hidden content |} Rendered result
Examples without a header row Wikitext {| class="wikitable mw-collapsible" |- | First row is always visible |- | Content that starts visible |} Rendered result
Wikitext {| class="wikitable mw-collapsible mw-collapsed" |- | First row is always visible |- | Other rows start hidden |} Rendered result
Tables with captions Tables with captions will collapse to the table caption. The header will not be visible when collapsed. Use {{nowrap}} to keep the caption from being fit into a tiny vertical column when the table is collapsed. Wikitext {| class="wikitable mw-collapsible" |+{{nowrap|Somewhat long table caption}} |- ! Header |- | Content starts visible |- | More visible content |} Rendered result.
Rendered result
Starting off collapsed: Wikitext {| class="wikitable mw-collapsible mw-collapsed" |+{{nowrap|Somewhat long table caption}} |- ! Header |- | Content starts hidden |- | More hidden content |} Rendered result.
Rendered result
Sorting and collapsing It is possible to collapse a sortable table. To do so, you need to use this code:
For example: Wikitext {| class="wikitable sortable mw-collapsible" |+ Sortable and collapsible table |- ! scope=col | Alphabetic ! scope=col | Numeric ! scope=col | Date ! scope=col class=unsortable | Unsortable |- | d || 20 || 2008-11-24 || This |- | b || 8 || 2004-03-01 || column |- | a || 6 || 1979-07-23 || cannot |- | c || 4.2 || 1492-12-08 || be |- | e || 0 || 1601-08-13 || sorted. |} Rendered result
If you want the table to default to collapsed state, use the code
in place of
Highlight rows on hoverNote: For usage examples, etc. go to {{row hover highlight}}. To highlight rows upon hover, add {{row hover highlight}} (or its alias, {{mw-datatable}}) just above the table wikitext. This enables use of Colors in tablesGuidelines, help, info: Manual of Style/Tables, MOS:COLOR (guideline), Help:Using colours, List of colors, Web colors.
Contrast tools: WebAIM: Contrast Checker, {{Color contrast ratio}}, {{Greater color contrast ratio}}, {{Color contrast conformance}}.
Color blindness: Help:Using colours#Schemes for colour-blind readers.
Background colors are common in table cells. In many sports articles for example. See here. For the accessibility reasons stated in WP:COLOR, information should not be communicated by the use of color alone. Two ways of specifying color of text and background for a single cell are as follows: Wikitext {| |- | style="background-color: red; color: white;"|abc | def | style="background-color: red;"|<span style="color: white;">ghi</span> | jkl |} Produces
Like other parameters, colors can also be specified for a whole row or the whole table; parameters for a row override the value for the table, and those for a cell override those for a row. There is no easy way to specify a color for a whole column: each cell in the column must be individually specified. Tools can make it easier. Wiki markup {| style="background-color: yellow; color: green;" |- | stu || style="background-color: silver;" | vwx || yz |- style="background-color: red; color: white;" | stu || style="background-color: silver;" | vwx || yz |- | stu || style="background-color: silver;" | vwx || yz |} Produces
To force a cell to match one of the default colors of the Avoid background:none or transparentAvoid using Background colors for column headers
Color contrast with visited and unvisited linksSee the link colors for various skins: Help:Link color#Standard colors. Unvisited Vector link: #3366CC. Visited Vector link: #795CB2. Test contrast of link color with background color and text color: Substitute various background colors for the default white Vector background (#FFFFFF):
From MOS:COLORS: For the default Vector 2022 skin normal text color is #202122, and unvisited blue link is #3366CC. "When links and references are not present, extra contrast is possible by setting the text color to pure black (#000000). If a dark background is desired, it should be used against white text (#FFFFFF) without links or references." Color contrast of links in dark modeIn dark mode in article namespace table cells with background colors have black underlined links. For example:
So any cell with WCAG-acceptable link color contrast in light mode has even better link color contrast in dark mode. Unfortunately, the links are only black in article namespace. Not in template, help, talk, user, and other namespaces. For example see the Spain table template from the above-linked article: Template:2022–23 La Liga table. Breaking up tables without losing colorsNormally, copying and pasting columns or rows removes the inline CSS styling such as cell colors. There is a way to break up a table (a too-wide table for example) into more tables without losing all the background colors, and other inline styling. Copy the table to 2 sandboxes (or one sandbox, and in the article itself). Then delete the columns not needed on one of the new tables. Repeat in the other sandbox (or in the article) except delete different columns. See also
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||