-
Notifications
You must be signed in to change notification settings - Fork 0
10 Tables
Tables can be constructed in both Markdown and HTML.
It is fair to say that Markdown tables are very simplistic in nature and do not offer a great deal of flexibility: they always have a heading across the top (vertical headings cannot be accommodated), they have limited alignment capabilities (horizontal alignment is possible, but vertical alignments are not. Similarly the table alignment on the page is not possible) and they do not support the merging of cells.
Markdown tables are only suitable for very straight forward tables.
That said, Markdown tables have the appearance of tables in the Markdown and are easy to understand.
HTML tables on the other hand offer a very great deal of flexibility (they can do all the things listed in the Markdown limitations above) and allow the tables to be used as containers for other things: images, ordered and unordered lists, text blocks &c.
The disadvantage of HTML tables is that they are harder to understand when built in Markdown (each cell is on its own line, it’s harder to identify rows and columns). A second disadvantage is that HTML tables do not lend themselves to the direct import of spreadsheet cells (this may seem a slightly odd point, but it is a common activity to copy data from a spreadsheet to a Wiki page) the data has to be manipulated before it can be copied to the Markdown file.
The PracticalSeries Wikis use both types of tables, but mainly HTML ones.
Tables in Markdown are pretty simple; they use the pipe character |
to separate cells and three or more dashes ---
to identify the column header.
The easiest way to explain it is to show an example:
Markdown and GitHub output | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|||||||||||||||
| Head 1 | Head 2 | Head 3 |
|--------|--------|--------|
| Row 1a | Row 1b | Row 1c |
| Row 2a | Row 2b | Row 2c |
| Row 3a | Row 3b | Row 3c |
| Row 4a | Row 4b | Row 4c |
| |||||||||||||||
|
|||||||||||||||
| |||||||||||||||
Table 10.1 — A simple Markdown table |
The header row is always in bold, and alternate table body rows are shaded light grey rgb (246,248,250)
, #F6F8FA
.
Markdown tables are always left aligned on the page.
There is nothing that can be done about this with Markdown tables (however, there is with HTML tables, see section 10.2).
By default the text in the heading cells is centred and the text in the body cells is left aligned:
Markdown and GitHub output | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
|||||||||
| Head 1 | Head 2 | Head 3 |
|-------------|-------------|-------------|
| Row 1a | Row 1b | Row 1c |
| Row 2a text | Row 2b text | Row 2c text |
| |||||||||
|
|||||||||
| |||||||||
Table 10.2 — Markdown table default alignment |
The horizontal alignment can be changed by adding colons (:) to the row of dashes:
Markdown and GitHub output | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
|||||||||
| Head 1 | Head 2 | Head 3 |
|:------------|:-----------:|------------:|
| Left | Centred | Right |
| Row 2a text | Row 2b text | Row 2c text |
| |||||||||
|
|||||||||
| |||||||||
Table 10.3 — Markdown table modified alignments |
The colons have the following meanings:
Symbol | Alignment |
---|---|
:--- |
Align left horizontally |
:---: |
Centred horizontally |
---: |
Align right horizontally |
Table 10.4 — Markdown horizontal alignment |
If the alignment is changed, the heading cells will follow the same alignment.
In the previous example, everything was nicely lined up. Most people do this when building Markdown tables (I think it’s an inherent sense of neatness).
It is not however, necessary. The following works perfectly well:
Markdown and GitHub output | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
|||||||||
|Head 1|Head 2|Head 3|
|:---|:---:|---:|
|Left| Centred|Right|
|Row 2a text|Row 2b text|Row 2c text|
| |||||||||
|
|||||||||
| |||||||||
Table 10.5 — Minimalist Markdown table |
The only requirement is that there must be at least three dashes between the pipes in the column header row.
The first and last pipes on each row are not technically needed, GitHub works it out:
Markdown and GitHub output | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
|||||||||
Head 1|Head 2|Head 3
:---|:---:|---:
Left| Centred|Right
Row 2a text|Row 2b text|Row 2c text
| |||||||||
|
|||||||||
| |||||||||
Table 10.6 — Minimalist Markdown table without start and end pipes |
Even so, don’t do this, other Markdown parsers do need the start and end pipes, plus it makes the table look better in Markdown.
It is possible to add additional lines to a cell by using the
element (see section 6.2.1):
Markdown and GitHub output | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
|||||||||
| Head 1 | Head 2 | Head 3 |
|--------|--------|--------|
| Line 1<br>Line 2<br>Line 3 | Row 1b | Row 1c |
| Row 2a | Row 2b | Row 2c |
| |||||||||
|
|||||||||
| |||||||||
Table 10.7 — Line breaks in a Markdown table |
The <br>
forces a line break within the cell.
The vertical alignment of cells in a Markdown table is always centred, this can be seen in the alignment of text in the cells Row 1b and Row 1c. There is nothing that can be done about this alignment in Markdown (vertical alignment can be changed in HTML tables, see section 10.2.7).
By default, the width of a column in a table is determined by the longest text in any cell in the column.
It is possible to force a column to a given width by adding special space characters (see section 7.2) such as the em-space  
to cells in the header row (it works in the body text too, but the header row is the most obvious place):
Markdown and GitHub output | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
|||||||||
| Wide 1     | Head 2 | Head 3 |
|--------|--------|--------|
| Row 1a | Row 1b | Row 1c |
| Row 2a | Row 2b | Row 2c |
| |||||||||
|
|||||||||
| |||||||||
Table 10.8 — Changing the width of a column |
It has to be the special space characters, if the cell is padded with multiple spaces (from the space bar), these will be ignored (see section 6.1.3)
All the normal forms of emphasis (bold, italic &c.) can be used in tables. Block quotes and alerts however, cannot.
All escape characters, emojis and escape sequences can also be used, as can code fragments (see section 13) and footnotes (see section 12.6).
All types of links (see section 9) and figures (see section 11) can be used in tables.
This is a list of the things you can’t do with Markdown tables:
❶ | The header row cannot be absent (Markdown tables always have a header row) |
❷ | Headers cannot be arranged down a column |
❸ | Cells cannot be merged together or spanned |
❹ | The table cannot be centred on a page (always left-aligned) |
❺ | Cells cannot be vertically aligned |
List 10.1 — Markdown table restrictions |
---|
HTML tables do not have any of these restrictions and generally offer much more flexi-bility.
HTML tables are very dated now (in HTML terms), they have largely been overtaken by grids and flexbox arrangements, unfortunately both of these require CSS and that is forbidden on GitHub markdown pages.
This leaves us with the old-fashioned HTML <table>
, this has been around pretty much from the start of HTML (sometime in the 90s) and has remained largely unchanged ever since. GitHub operates a restricted version of the HTML <table>
tag (there are something it can’t do, such as change fonts or colours), but even with these restrictions HTML tables are much more flexible than Markdown tables.
I’m going to assume a degree of knowledge about HTML tables and how they work, just the basics. If you are completely unfamiliar with HTML tables, I have a website that explains them: PracticalSeries Basic Guide to HTML tables.
Tables are defined with the <table>...</table>
element. Each row of a table is enclosed in <tr>...</tr>
elements and these are stacked one on top of the other. Within a given row, each cell is enclosed in either <th>...</th>
tags or <td>...</td>
tags.
The <th>
tags contain a single cell that acts as a header (table header is what it stands for) or label for the column. The <td
> tags (table data) are standard cells within a table that contain some information.
Look at this table for example:
Mileage | Birmingham | Liverpool | London | Manchester | Newcastle |
---|---|---|---|---|---|
Birmingham | 0 | 113 | 126 | 87 | 146 |
Liverpool | 113 | 0 | 221 | 34 | 174 |
London | 126 | 221 | 0 | 209 | 283 |
Manchester | 87 | 34 | 209 | 0 | 145 |
Newcastle | 146 | 174 | 283 | 145 | 0 |
Figure 10.1 — A basic table |
This table has 6 rows and each row has 6 cells (it’s a 6×6 table). The top row is acting as a header for each of the columns and the first cell in each row is also a header.
At the most basic level, the HTML would be constructed as follows:
![]() |
Figure 10.2 — HTML structure for a basic table |
---|
The HTML for the above table is:
HTML and GitHub output | ||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||||||||||||||||||||||||||||||||
<table>
<tr>
<th>Mileage</th><th>Birmingham</th><th>Liverpool</th><th>London</th><th>Manchester</th><th>Newcastle</th>
</tr>
<tr>
<th>Birmingham</th><td>0</td><td>113</td><td>126</td><td>87</td><td>146</td>
</tr>
<tr>
<th>Liverpool</th><td>113</td><td>0</td><td>221</td><td>34</td><td>174</td>
</tr>
<tr>
<th>London</th><td>126</td><td>221</td><td>0</td><td>209</td><td>283</td>
</tr>
<tr>
<th>Manchester</th><td>87</td><td>34</td><td>209</td><td>0</td><td>145</td>
</tr>
<tr>
<th>Newcastle</th><td>146</td><td>174</td><td>283</td><td>145</td><td>0</td>
</tr>
</table>
| ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||
Table 10.9 — HTML for a basic table |
Once again, we can see that GitHub does certain things: the headings (everything within a <th>
tag) is in bold and centred, the data cells (everything within a <td>
tag) are left-aligned and alternate rows are shaded just like the Markdown table.
Note
One slight difference between the Markdown table and the HTML table; with a Markdown table the heading row always has a white background and so does the first row of the cells below the heading. With HTML, the first row (irrespective of whether it is a header row or not) is always white and the second row always shaded. I.e. with a Markdown table the shading starts on the third row, with HTML tables, the shading starts on the second row.
There is no requirement for a table to have any heading <th>
cells, the whole thing could be constructed using <td>
cells.
Unlike Markdown, HTML tables can be aligned on the GitHub web page. By default HTML tables are left-aligned on a page (just like the Markdown tables).
Consider the following:
HTML and GitHub output | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||||||||
<table>
<tr>
<th>Head 1</th><th>Head 2</th><th>Head 3</th>
</tr>
<tr>
<td>Row 1a</td><td> Row 1b</td><td> Row 1c</td>
</tr>
<tr>
<td>Row 2a</td><td> Row 2b</td><td> Row 2c</td>
</tr>
<tr>
<td>Row 3a</td><td> Row 3b</td><td> Row 3c</td>
</tr>
</table>
| ||||||||||||
|
||||||||||||
| ||||||||||||
Table 10.10 — HTML default table alignment |
This is the default arrangement, the table is aligned to the left side of the page.
The <table>
tag accepts the
<th align="left">${\large \color{#00C050}\text{H\ T\ M\ L}}$ 🔽</th>
</tr>
HTML and GitHub output | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
<table align="center">
<tr>
<th>Head 1</th><th>Head 2</th><th>Head 3</th>
</tr>
<tr>
<td>Row 1a</td><td> Row 1b</td><td> Row 1c</td>
</tr>
<tr>
<td>Row 2a</td><td> Row 2b</td><td> Row 2c</td>
</tr>
<tr>
<td>Row 3a</td><td> Row 3b</td><td> Row 3c</td>
</tr>
</table>
| ||||||||||||
|
||||||||||||
| ||||||||||||
Table 10.11 — HTML centred table alignment |
The
Note
Center uses the American spelling
Using
HTML and GitHub output | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||||||||
<table align="right">
<tr>
<th>Head 1</th><th>Head 2</th><th>Head 3</th>
</tr>
<tr>
<td>Row 1a</td><td> Row 1b</td><td> Row 1c</td>
</tr>
<tr>
<td>Row 2a</td><td> Row 2b</td><td> Row 2c</td>
</tr>
<tr>
<td>Row 3a</td><td> Row 3b</td><td> Row 3c</td>
</tr>
</table>
| ||||||||||||
|
||||||||||||
| ||||||||||||
Table 10.12 — HTML right aligned table |
Finally
HTML and GitHub output | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||||||||
<table align="left">
<tr>
<th>Head 1</th><th>Head 2</th><th>Head 3</th>
</tr>
<tr>
<td>Row 1a</td><td> Row 1b</td><td> Row 1c</td>
</tr>
<tr>
<td>Row 2a</td><td> Row 2b</td><td> Row 2c</td>
</tr>
<tr>
<td>Row 3a</td><td> Row 3b</td><td> Row 3c</td>
</tr>
</table>
| ||||||||||||
|
||||||||||||
| ||||||||||||
Table 10.13 — HTML left aligned table |
Hmm, I found this out by accident and I’ve not seen it referenced anywhere else (and I’ve done a lot of searches in the course of writing this).
It is possible to have two (or more) tables side by side on the page. Look at the following:
HTML and GitHub output | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||||||||||||||
<table>
<tr>
<th>Table 1 H1</th><th> Table 1 H2</th><th> Table 1 H3</th>
</tr>
<tr>
<td>Row 1a</td><td> Row 1b</td><td> Row 1c</td>
</tr>
<tr>
<td>Row 2a</td><td> Row 2b</td><td> Row 2c</td>
</tr>
</table>
<table
<tr>
<th>Table 2 H1</th><th> Table 2 H2</th><th> Table 2 H3</th>
</tr>
<tr>
<td>Row 1a</td><td> Row 1b</td><td> Row 1c</td>
</tr>
<tr>
<td>Row 2a</td><td> Row 2b</td><td> Row 2c</td>
</tr>
</table>
| ||||||||||||||||||
|
||||||||||||||||||
| ||||||||||||||||||
Table 10.14 — HTML two tables one above the other |
Two tables one above the other. Pretty much what you would expect.
Now change the <table>
tab for the first table to include the
HTML and GitHub output | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||||||||||||||
<table align="right">
<tr>
<th>Table 1 H1</th><th> Table 1 H2</th><th> Table 1 H3</th>
</tr>
<tr>
<td>Row 1a</td><td> Row 1b</td><td> Row 1c</td>
</tr>
<tr>
<td>Row 2a</td><td> Row 2b</td><td> Row 2c</td>
</tr>
</table>
<table>
<tr>
<th>Table 2 H1</th><th> Table 2 H2</th><th> Table 2 H3</th>
</tr>
<tr>
<td>Row 1a</td><td> Row 1b</td><td> Row 1c</td>
</tr>
<tr>
<td>Row 2a</td><td> Row 2b</td><td> Row 2c</td>
</tr>
</table>
| ||||||||||||||||||
|
||||||||||||||||||
| ||||||||||||||||||
Table 10.15 — HTML two tables side by side |
Table 1 has moved over to the right (like it was told it to), but Table 2 has sort of moved up into the gap it left on the other side.
This is slightly peculiar behaviour. Try it with some text instead of Table 2:
HTML and GitHub output | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
|||||||||
<table align="right">
<tr>
<th>Table 1 H1</th><th> Table 1 H2</th><th> Table 1 H3</th>
</tr>
<tr>
<td>Row 1a</td><td> Row 1b</td><td> Row 1c</td>
</tr>
<tr>
<td>Row 2a</td><td> Row 2b</td><td> Row 2c</td>
</tr>
</table>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. In consectetur tortor
a tortor ornare, non pretium diam faucibus. Morbi ut mollis dolor, nec pretium
tellus. Suspendisse ornare neque placerat orci aliquam, eu sodales dui blandit.
| |||||||||
|
|||||||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. In consectetur tortor a tortor ornare, non pretium diam faucibus. Morbi ut mollis dolor, nec pretium tellus. Suspendisse ornare neque placerat orci aliquam, eu sodales dui blandit. | |||||||||
Table 10.16 — HTML right aligned table followed by text |
Changing
HTML and GitHub output | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
|||||||||
<table align="left">
<tr>
<th>Table 1 H1</th><th> Table 1 H2</th><th> Table 1 H3</th>
</tr>
<tr>
<td>Row 1a</td><td> Row 1b</td><td> Row 1c</td>
</tr>
<tr>
<td>Row 2a</td><td> Row 2b</td><td> Row 2c</td>
</tr>
</table>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. In consectetur tortor
a tortor ornare, non pretium diam faucibus. Morbi ut mollis dolor, nec pretium
tellus. Suspendisse ornare neque placerat orci aliquam, eu sodales dui blandit.
| |||||||||
|
|||||||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. In consectetur tortor a tortor ornare, non pretium diam faucibus. Morbi ut mollis dolor, nec pretium tellus. Suspendisse ornare neque placerat orci aliquam, eu sodales dui blandit. |
And finally,
HTML and GitHub output | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
|||||||||
<table align="center">
<tr>
<th>Table 1 H1</th><th> Table 1 H2</th><th> Table 1 H3</th>
</tr>
<tr>
<td>Row 1a</td><td> Row 1b</td><td> Row 1c</td>
</tr>
<tr>
<td>Row 2a</td><td> Row 2b</td><td> Row 2c</td>
</tr>
</table>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. In consectetur tortor
a tortor ornare, non pretium diam faucibus. Morbi ut mollis dolor, nec pretium
tellus. Suspendisse ornare neque placerat orci aliquam, eu sodales dui blandit.
| |||||||||
|
|||||||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. In consectetur tortor a tortor ornare, non pretium diam faucibus. Morbi ut mollis dolor, nec pretium tellus. Suspendisse ornare neque placerat orci aliquam, eu sodales dui blandit. |
So what is going on?
It seems that when the
Normally, when defining a table it starts on a new line and anything that follows it starts on the next new line after the table. HTML elements like this are called block elements.
Inline block elements do not do this. Inline block elements only take up as much space on a line as they need for their width, the remaining space on the line is taken up with whatever follows the inline block element (I have a website explaining this here).
It seems that when we use the
At first, I thought this was a peculiarity of GitHub (I thought GitHub might be doing something either intentionally or unintentionally to make the table an inline object), but it is not. When I created my own web page (a proper web page, not anything to do with GitHub or Markdown) with a table and did the same experiment, the browser did exactly the same thing. Without the
With
What this means is that it is possible to wrap text around a table and this can look quite nice if that is what you want to do:
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit voluptate velit esse cillum dolore fugiat nulla pariatur. Excepteur sint. Lorem ipsum dolor sit amet, consectetur adipiscing elit. In consectetur tortor a tortor ornare, non pretium diam faucibus. Morbi ut mollis dolor, nec pretium tellus. Suspendisse ornare neque placerat orci aliquam, eu sodales dui blandit. | |||||||||
Figure 10.3 — HTML text wrap around a table |
---|
And, as we saw earlier, it also allows two tables to be side by side:
| ||||||||||||||||||
Figure 10.4 — HTML two tables side by side |
---|
The Table 1 has the
Yes, there is a problem. Once you open up the inline block elements and have them floating left and right, things get a bit carried away. Look at the following:
HTML and GitHub output | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||||||||||||||
<table align="left">
<tr>
<th>Table 1 H1</th><th> Table 1 H2</th><th> Table 1 H3</th>
</tr>
<tr>
<td>Row 1a</td><td> Row 1b</td><td> Row 1c</td>
</tr>
<tr>
<td>Row 2a</td><td> Row 2b</td><td> Row 2c</td>
</tr>
</table>
<table align="right">
<tr>
<th>Table 2 H1</th><th> Table 2 H2</th><th> Table 2 H3</th>
</tr>
<tr>
<td>Row 1a</td><td> Row 1b</td><td> Row 1c</td>
</tr>
<tr>
<td>Row 2a</td><td> Row 2b</td><td> Row 2c</td>
</tr>
</table>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. In consectetur tortor
a tortor ornare, non pretium diam faucibus. Morbi ut mollis dolor, nec pretium
tellus. Suspendisse ornare neque placerat orci aliquam, eu sodales dui blandit.
| ||||||||||||||||||
|
||||||||||||||||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. In consectetur tortor a tortor ornare, non pretium diam faucibus. Morbi ut mollis dolor, nec pretium tellus. Suspendisse ornare neque placerat orci aliquam, eu sodales dui blandit. | ||||||||||||||||||
Table 10.17 — HTML problems with floating tables |
This is the code for the side-by-side, but with some lorem ipsum text afterwards.
It probably isn’t what is wanted.
The problem is that once you start down the route of making elements float (turn them into inline elements), it’s hard to put the genie back in the bottle.
Fortunately it is quite easy to stop the text (and anything else) from wrapping around these floating inline objects (although it took me ages to find out how).
To stop text wrapping around a floating inline object, use a special form of the line break command <br>
.
The <br
> tag supports the
Using this, the previous example becomes:
HTML and GitHub output | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||||||||||||||
<table align="left">
<tr>
<th>Table 1 H1</th><th> Table 1 H2</th><th> Table 1 H3</th>
</tr>
<tr>
<td>Row 1a</td><td> Row 1b</td><td> Row 1c</td>
</tr>
<tr>
<td>Row 2a</td><td> Row 2b</td><td> Row 2c</td>
</tr>
</table>
<table align="right">
<tr>
<th>Table 2 H1</th><th> Table 2 H2</th><th> Table 2 H3</th>
</tr>
<tr>
<td>Row 1a</td><td> Row 1b</td><td> Row 1c</td>
</tr>
<tr>
<td>Row 2a</td><td> Row 2b</td><td> Row 2c</td>
</tr>
</table>
<br clear="all">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. In consectetur tortor
a tortor ornare, non pretium diam faucibus. Morbi ut mollis dolor, nec pretium
tellus. Suspendisse ornare neque placerat orci aliquam, eu sodales dui blandit.
| ||||||||||||||||||
|
||||||||||||||||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. In consectetur tortor a tortor ornare, non pretium diam faucibus. Morbi ut mollis dolor, nec pretium tellus. Suspendisse ornare neque placerat orci aliquam, eu sodales dui blandit. | ||||||||||||||||||
Table 10.18 — HTML fixing the text wrap problem |
Using the
This is it between a left aligned table and right aligned table:
HTML and GitHub output | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||||||||
<table align="left">
<tr>
<th>Table 1 H1</th><th> Table 1 H2</th><th> Table 1 H3</th>
</tr>
<tr>
<td>Row 1a</td><td> Row 1b</td><td> Row 1c</td>
</tr>
</table>
<br clear="all">
<table align="right">
<tr>
<th>Table 2 H1</th><th> Table 2 H2</th><th> Table 2 H3</th>
</tr>
<tr>
<td>Row 1a</td><td> Row 1b</td><td> Row 1c</td>
</tr>
</table>
| ||||||||||||
|
||||||||||||
| ||||||||||||
Table 10.19 — HTML left and right align table without wrap |
Note
There doesn’t have to be blank lines around the <br clear="all">
tag.
With Markdown tables the width of the table could only be adjusted by adding special space characters to for the columns to be wider.
With HTML things are a bit more sophisticated, the <th>
and <td>
tags support the
HTML and GitHub output | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
|||||||||
<table>
<tr>
<th width="300">Head 1</th><th width="250">Head 2</th><th width="200">Head 3</th>
</tr>
<tr>
<td>Row 1a</td><td> Row 1b</td><td> Row 1c</td>
</tr>
<tr>
<td>Row 2a</td><td> Row 2b</td><td> Row 2c</td>
</tr>
</table>
| |||||||||
|
|||||||||
| |||||||||
Table 10.20 — Setting the width of table columns in pixels |
Looking at this table in detail:
![]() |
Figure 10.5 — Measured width of table columns in pixels |
---|
The first column (left side) is exactly 300 px wide, the second (middle) is exactly 250 px wide and the third (right side) column is exactly 200 px wide.
Note
The maximum width of a table is 896 px (see section 6.1.1). If the width values add up to more than this, then the widths will reduce in proportion (ish) until they fit the page area . This reduction feature is done by the browser rather than GitHub and the exact result depends on the browser being used.
Unlike Markdown, it is possible to set the hight of a cell in HTML tables to a specific value (analogous to the
Like the <th>
and <td>
tags support the
The height attribute is in the form
HTML and GitHub output | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
|||||||||
<table>
<tr>
<th>Head 1</th><th>Head 2</th><th>Head 3</th>
</tr>
<tr>
<td height="100">Row 1a</td><td> Row 1b</td><td> Row 1c</td>
</tr>
<tr>
<td>Row 2a</td><td> Row 2b</td><td> Row 2c</td>
</tr>
</table>
| |||||||||
|
|||||||||
| |||||||||
Table 10.21 — HTML setting the height of table row in pixels |
Looking at this table in detail:
![]() |
Figure 10.6 — Measured height of table rows in pixels |
---|
Row 1 (middle) is exactly 100 px high.
Note
There is no restriction on the height of a cell (unlike the width where the table has a maximum width to fit on a page), the web page just gets longer to accommodate it.
The height
attribute can also be applied to a whole row from within the <tr>
tag. E.g. <tr height="100">
. Under these circumstances, the row height will be overridden if a particular cell, has its own height
attribute with a greater height value.
The
HTML and GitHub output | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
|||||||||
<table>
<tr>
<th>Wide Heading 1</th><th>Wide Heading 2</th><th>Wide Heading 3</th>
</tr>
<tr>
<td td align="left">Row 1a</td><td align="center"> Row 1b</td><td align="right"> Row 1c</td>
</tr>
<tr>
<td>Row 2a</td><td> Row 2b</td><td> Row 2c</td>
</tr>
</table>
| |||||||||
|
|||||||||
| |||||||||
Table 10.22 — HTML setting the horizontal alignment of text in a cell |
The wide headings are just to make the columns wider and the effects more visible.
The first cell in row 1 is left-aligned, the second centred and the third right-aligned.
Note
The align
attribute can also be applied to a whole row from within the <tr>
tag. E.g. <tr align="center">
. Under these circumstances, the row alignment will be overridden for a particular cell, if that cell has its own align
attribute.
Vertical alignment wasn’t possible with Markdown tables. HTML tables, however, do support vertical alignment with the use of the
The <th>
and <td>
tags:
HTML and GitHub output | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
|||||||||
<table>
<tr>
<th>Wide Heading 1</th><th>Wide Heading 2</th><th>Wide Heading 3</th>
</tr>
<tr>
<td height="100" valign="top">Row 1a</td><td valign="middle"> Row 1b</td><td valign="bottom"> Row 1c</td>
</tr>
<tr>
<td>Row 2a</td><td> Row 2b</td><td> Row 2c</td>
</tr>
</table>
| |||||||||
|
|||||||||
| |||||||||
Table 10.23 — HTML setting the vertical alignment of a cell |
The
The first cell is top-aligned, the second aligned in the middle and the third bottom-aligned.
It is perfectly possible to mix horizontal and vertical alignments:
Would centre the text both horizontally and vertically.
Note
The valign
attribute can also be applied to a whole row from within the <tr>
tag. E.g. <tr valign="top">
. Under these circumstances, the row alignment will be overridden for a particular cell, if that cell has its own valign
attribute.
With HTML tables, it is possible to make a cell span multiple columns or multiple rows using either the
The <th>
and <td>
tags support the
HTML and GitHub output | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|||||||||||||||
<table>
<tr>
<th>Heading 1</th><th>Heading 2</th><th>Heading 3</th><th>Heading 3</th>
</tr>
<tr>
<td colspan="2">Row 1a/b</td><td>Row 1c</td><td rowspan="2">Row 1d/2d</td>
</tr>
<tr>
<td>Row 2a</td><td>Row 2b</td><td>Row 2c</td>
</tr>
<tr>
<td>Row 3a</td><td colspan="3">Row 3b/c/d</td>
</tr>
</table>
| |||||||||||||||
|
|||||||||||||||
| |||||||||||||||
Table 10.24 — HTML merging cells in a table |
There are two
When using
This is an oddball thing; I think it exists more by accident than anything else.
Generally, all tables in a Wiki look the same when rendered by GitHub:
HTML and GitHub output | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||||||||
<table>
<tr>
<th>Head 1</th><th>Head 2</th><th>Head 3</th>
</tr>
<tr>
<td>Row 1a</td><td> Row 1b</td><td> Row 1c</td>
</tr>
<tr>
<td>Row 2a</td><td> Row 2b</td><td> Row 2c</td>
</tr>
<tr>
<td>Row 3a</td><td> Row 3b</td><td> Row 3c</td>
</tr>
</table>
| ||||||||||||
|
||||||||||||
| ||||||||||||
Table 10.25 — HTML basic table in GitHub |
Headings in bold, alternate rows shaded and all cells have a 1-pixel border in a slightly darker shade of grey than the shading rgb (209,217,224) #D1D9E0
.
There is a very old HTML tag called
HTML and GitHub output | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||||||||
<table border="1">
<tr>
<th>Head 1</th><th>Head 2</th><th>Head 3</th>
</tr>
<tr>
<td>Row 1a</td><td> Row 1b</td><td> Row 1c</td>
</tr>
<tr>
<td>Row 2a</td><td> Row 2b</td><td> Row 2c</td>
</tr>
<tr>
<td>Row 3a</td><td> Row 3b</td><td> Row 3c</td>
</tr>
</table>
| ||||||||||||
|
||||||||||||
| ||||||||||||
Table 10.26 — HTML setting the border of a table |
The table gets a darker border rgb (44,44,44) #2C2C2C
around the outside.
Setting border="0" just puts the table back how it was.
That is it, that is all that can be done in terms of modifying the border of a table.
It is often useful to be able to navigate to a table if it is reference elsewhere in the Wiki, this was explained in section 9.5, but is covered here specifically in terms of a table.
To make a table a navigable point (something that can be linked to from another point in the Wiki or even from an external website), the <table>
tag is assigned a
HTML |
---|
|
<table name="idName">
|
The
This is a worked example:
HTML and GitHub output | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|||||||||||||||
<table name="t-10-51">
<tr>
<th>Head 1</th><th>Head 2</th><th>Head 3</th>
</tr>
<tr>
<td>Row 1a</td><td> Row 1b</td><td> Row 1c</td>
</tr>
<tr>
<td>Row 2a</td><td> Row 2b</td><td> Row 2c</td>
</tr>
<tr>
<td>Row 3a</td><td> Row 3b</td><td> Row 3c</td>
</tr>
<tr>
<td colspan="3">Table 10.51</td>
</tr>
</table>
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
This is a link to [Table 10.11](#t-10-11)
| |||||||||||||||
|
|||||||||||||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. This is a link to Table 10.51 | |||||||||||||||
Table 10.27 — HTML assigning a name to a table |
The link: [Table 10.51](#t-10-51)
is the standard form of Markdown link covered in detail in section 9.5.
The HTML tags used in all the previous examples are:
HTML tag | Meaning |
---|---|
<table>...</table> |
Defines the start and end of a table |
<tr>...</tr> |
Defines the start and end of a table row |
<th>...</th> |
Defines the start and end of a table heading cell |
<td>...</td> |
Defines the start and end of a table data cell |
Table 10.28 — Standard HTML table tags |
HTML supports some additional table tags:
HTML tag | Meaning |
---|---|
<thead>...</thead> |
Used to group the heading content of a table |
<tbody>...</tbody> |
Used to group the body of a table |
<tfoot>...</tfoot> |
Identifies any footer that the table may have |
Table 10.29 — Additional HTML table tags |
A typical table (exactly like all the ones we have used so far) would have the code:
HTML and GitHub output | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|||||||||||||||
<table>
<tr>
<th>Head 1</th><th>Head 2</th><th>Head 3</th>
</tr>
<tr>
<td>Row 1a</td><td> Row 1b</td><td> Row 1c</td>
</tr>
<tr>
<td>Row 2a</td><td> Row 2b</td><td> Row 2c</td>
</tr>
<tr>
<td>Row 3a</td><td> Row 3b</td><td> Row 3c</td>
</tr>
<tr>
<td colspan="3">Table 10.52</td>
</tr>
</table>
| |||||||||||||||
|
|||||||||||||||
| |||||||||||||||
Table 10.30 — HTML a typical type of table |
Using the additional tags, this would become:
HTML and GitHub output | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|||||||||||||||
<table>
<thead>
<tr>
<th>Head 1</th><th>Head 2</th><th>Head 3</th>
</tr>
</thead>
<tbody>
<tr>
<td>Row 1a</td><td> Row 1b</td><td> Row 1c</td>
</tr>
<tr>
<td>Row 2a</td><td> Row 2b</td><td> Row 2c</td>
</tr>
<tr>
<td>Row 3a</td><td> Row 3b</td><td> Row 3c</td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="3">Table 10.52</td>
</tr>
</tfoot>
</table>
| |||||||||||||||
|
|||||||||||||||
| |||||||||||||||
Table 10.31 — A table with the additional tags |
These additional tags were introduced to better define the different areas of the table to make the HTML more definitive.
These additional tags make absolutely no difference to how the table looks.
Use them if you wish (it’s probably better HTML). The PracticalSeries Wikis does not use them, more for historical reasons rather than anything else.
Footnotes:
Note
💠1 The width attribute usually sets the width of the element in pixels, this is the default. It can also set the width as a percentage of the containing element width. This percentage measure is no longer supported (it was very confusing) and only the default pixel measurement is now used.↩
-
10Tables
- 10.1Markdown tables
-
10.2HTML tables
- 10.2.1A basic HTML table
- 10.2.2Aligning a table on a page
- 10.2.3Text wrap and side-by-side tables
- 10.2.4Setting the width of a table column
- 10.2.5Setting the height of a table row
- 10.2.6Horizontal alignment
- 10.2.7Vertical alignment
- 10.2.8Spanning columns and rows
- 10.2.9Table border
- 10.2.10Giving a table a navigable name
- 10.2.11Additional HTML tags
|
|
|
|
|
The PracticalSeries of Publications — Copyright © 2025 Michael Gledhill
⬆️ Top | [email protected] | PracticalSeries of Publications | Main repository
|
|
|
|
|
Licence
The licences and other details
The Licence
Why did I choose the MIT Licence?
Permissive licences
Copyleft licence
Limiting liabilities
Which licence to use?
A note on spelling: licence or license
1 Introducing the GitHub Wiki
1.1 What are GitHub Wiki pages?
1.2 Understanding the Wiki pages
1.3 Creating a Wiki for a repository
1.3.1 Creating the first Wiki page
1.3.2 Creating additional pages
1.3.3 Editing a Wiki page
1.4 The Wiki is its own repository
1.4.1 Viewing a Wiki page history
1.4.2 How GitHub handles Wiki branche
1.4.3 The Wiki link to the main repository
1.5 Basic components of a Wiki page
1.5.1 Title bar and revision
1.5.2 Contents (pages) area
Listing pages in the order you want
1.5.3 Sidebars
1.5.4 Footers
1.6 Sidebars and footers
1.6.1 Creating a sidebar and footer
2 Cloning a Wiki
2.1 Why clone a Wiki?
2.2 How to clone a Wiki
2.3 Pushing local changes to GitHub
2.3.1 Configuring username and email
2.3.2 Modifying the local repository
2.3.3 Committing and synchronising
3 A Wiki folder structure
3.1 The default arrangement
3.2 Create a sidebar or footer locally
3.3 Page naming and Wiki limits
3.3.1 Supported file types
3.3.2 Page names and numbering
3.3.3 Rules for page numbering
3.3.4 Limits for Wiki pages
3.4 A Practical Wiki folder structure
3.4.1 Subfolder names for Wiki pages
3.4.2 Storing images and other data
4 Different sidebars and footers
4.1 How sidebars work
4.1.1 The PracticalSeries sidebar
4.2 How footers work
4.2.1 The PracticalSeries footer
5 Markdown, GitHub Markdown and HTML
5.1 Some useful Markdown sites
5.2 An overview of Markdown
5.3 How Markdown works
5.4 Markdown flavours
5.4.1 GitHub Flavoured Markdown (GFM)
5.5 HTML and Markdown
5.5.1 HTML with GFM
GFM blacklisted HTML tags
GFM whitelisted HTML tags
GFM HTML tags - the grey area
GFM whitelisted HTML attributes
5.5.2 PracticalSeries and Markdown
5.6 Markdown difference between files
6 Basic Markdown and text formatting
6.1 Body text and fonts
6.1.1 Body text responsive design
6.1.2 Body text in sidebars and footers
6.1.3 Rules for body text
6.1.4 Body text examples
6.1.5 Alignment of Body text
Left aligned text (default)
Right aligned text
Centred text
Justified text
6.1.6 Body text propertie
6.2 Paragraphs and line breaks
6.2.1 Forced line break
6.2.2 Blank line and a line break
6.2.3 Trailing space line break
6.2.4 Paragraph and line break rules
6.2.5 Paragraph and line break examples
6.3 Horizontal line
6.3.1 Rules for horizontal lines
6.4 Emphasis with bold
6.4.1 Rules for bold
6.4.2 Bold text examples
6.5 Emphasis with italics
6.5.1 Rules for italics
6.5.2 Italic text examples
6.6 Emphasis with bold and italics
6.6.1 Rules for bold and italics
6.6.2 Bold and italic text examples
6.7 Emphasis with underlining
6.7.1 Rules for underlining
6.7.2 Underlining text examples
6.8 Emphasis with strikethrough
6.8.1 Rules for strikethrough
6.8.2 Strikethrough text examples
6.9 Superscript and subscript
6.9.1 Rules for superscript and subscript
6.9.2 Superscript and subscript examples
6.10 Headings
Alternatives for heading 1 and 2
6.10.1 Headings Markdown rules
6.10.2 Heading properties
7 Special characters and escaping characters
7.1 Escape characters and codes
7.1.1 Markdown escape sequences
7.1.2 HTML escape sequences
7.1.3 Decimal and hexadecimal codes
Hexadecimal escape codes
7.2 Special space characters
7.2.1 Escape sequence restrictions
7.3 Emojis and emoticons
A note by the Author about emojis
7.4 Comments
8 Block quotes, lists and alerts
8.1 Block quotes
8.1.1 Nested block quotes
8.1.2 Adding other elements
8.1.3 Rules for block quotes
8.2 Unordered (unnumbered) lists
8.2.1 Nested unordered lists
8.2.2 Type of bullet point
8.2.3 Indents and spacing
8.2.4 Numbers in an unordered list
8.2.5 Adding paragraphs
8.2.6 Adding other elements
8.2.7 Rules for unordered lists
8.3 Ordered (numbered) lists
8.3.1 Starting at a different number
8.3.2 Nested ordered lists
8.3.3 Type of numbering
8.3.4 Indents and spacing
8.3.5 Adding paragraphs
8.3.6 Adding other elements
8.3.7 Rules for ordered lists
8.4 Mixing ordered and unordered lists
8.5 Task lists (check boxes)
8.5.1 Nested task lists
8.6 Alerts
8.6.1 Rules for alerts
9 Links
9.1 Link to an external web page
9.1.1 A direct link to a URL
9.1.2 A link using substitute text
9.1.3 A link using tooltips
9.2 Link to another page in the Wiki
9.2.1 Rules for linking to a Wiki page
9.3 Link to headings on current page
9.3.1 Converting a heading to a link
9.3.2 An example of a heading link
9.3.3 Heading link with tooltips
9.4 Link to headings on a different page
9.4.1 An example of a heading link
9.5 Link to a named element
A note by the Author
9.5.1 Link to a point on another page
9.6 Downloading a file
9.6.1 The download attribute
9.6.2 Spaces in filenames
9.6.3 Downloading a .md file
9.7 Reference style links
9.8 Relative links
9.8.1 Relative links from any Wiki page
10 Tables
10.1 Markdown tables
10.1.1 Horizontal alignment
10.1.2 Table construction
10.1.3 Vertical line breaks and alignment
10.1.4 Making columns wider
10.1.5 Other elements in a table
10.1.6 Markdown table restrictions
10.2 HTML tables
10.2.1 A basic HTML table
10.2.2 Aligning a table on a page
10.2.3 Text wrap and side-by-side tables
What this means in practice
The problem with the align attribute
How to stop text wrapping
10.2.4 Setting the width of a table column
10.2.5 Setting the height of a table row
10.2.6 Horizontal alignment
10.2.7 Vertical alignment
10.2.8 Spanning columns and rows
10.2.9 Table border
10.2.10 Giving a table a navigable name
10.2.11 Additional HTML tags
11 Images
11.1 Markdown images
11.1.1 Image size in Markdown
11.1.2 Making the image a link
11.1.3 Drag and drop image link
A note by the Author
11.2 HTML images
11.2.1 A basic HTML image
11.2.2 Image size in HTML
11.2.3 Horizontal alignment
11.2.4 Making the image a link
11.2.5 Using a table to contain an image
11.3 Forcing an image refresh
11.4 Using a spacer image
11.5 Mermaid diagrams
11.5.1 Inserting a Mermaid diagram
11.5.2 The rendered Mermaid diagram
11.5.3 Supported version of Mermaid
11.6 Interactive maps
11.7 3D models
12 Contents (collapsible) and footnotes
12.1 A basic table of contents
12.2 Understanding the space characters
12.3 Collapsible content
12.3.1 Defaulting to open
12.3.2 Markdown restrictions
12.4 Collapsible TOC
12.5 TOCs in tables
12.6 Footnotes
13 Code fragments
13.1 Inline code
13.2 Code blocks
13.2.1 Preferred mechanism
13.3 Syntax highlighting
13.3.1 Supported languages
13.4 HTML code fragments
13.4.1 Converting HTML to code
14 Mathematical formulae
14.1 An overview of LaTex
14.2 Inserting an inline formula
14.2.1 Alternative delimiter
14.3 A formula block
14.4 Some example formulae
14.5 LaTeX syntax
14.5.1 Greek lowercase
14.5.2 Greek uppercase and Hebrew
14.5.3 Mathematical constructions
14.5.4 Variable sized delimiters
14.5.5 Variable sized symbols
14.5.6 Variable sized symbols with limits
14.5.7 Standard functions
14.5.8 Operators and relational symbols
14.5.9 Arrows
14.5.10 Other symbols
14.5.11 Accents
14.5.12 Matrices
14.5.13 Cases
Aligning multiple equations
14.5.14 Text formatting
Font size
Font colour
The text command
Font restrictions
14.6 Abusing LaTeX
14.6.1 Changing font colour with LaTeX
15 Navigation bars, badges and buttons
15.1 Navigation bars
15.1.1 Navigation bar practicalities
15.2 Badges
15.2.1 Creating a badge
15.2.2 Static badge options
15.2.3 Dynamic badges
15.3 Buttons
16 PracticalSeries Wiki conventions
16.1 The PracticalSeries Wiki page
16.2 The PracticalSeries folder structure
16.2.1 The root folder and home page
16.2.2 Leading pages
16.2.3 .gitkeep files
16.2.4 Folder and Markdown file names
Wiki pages that start at a section
16.3 The page title area
16.4 The page heading area
16.4.1 Top of page marker
16.4.2 Logo image
16.4.3 Web ID badge
16.5 Main body area
16.5.1 Common page elements
End of page marker
End of section elements
16.5.2 Headings
Compensating for number widths
Appendices headings
16.5.3 Tables
Links to a table
A note on Markdown tables
16.5.4 Images
Images that open in a new tab
Double images
Links to a figure
16.5.5 Lists
Common points for all lists
Basic unordered list
Basic ordered list
Mixed ordered and unordered lists
Enhanced mixed lists
Index list
Reverse index list
Index list with text wrap
Reverse index list with text wrap
Indexed, mixed list
Reverse indexed, mixed list
Task list
Enhanced task list with observations
16.5.6 Code fragments
16.5.7 Formulae
Standard formulae
Alternate formulae
16.6 Sidebar
16.6.1 sidebar files and locations
16.6.2 Sidebar title and location badge
16.6.3 Navigation bar
16.6.4 Table of contents
Unnumbered, non-collapsible TOC
Unnumbered, collapsible TOC
Single digit, collapsible TOC
Double digit, collapsible TOC
TOCs for appendices
16.6.5 End of page link
16.7 Footer
16.7.1 Footer files and locations
16.7.2 Location badge
16.7.3 Navigation bar
16.7.4 Colophon
16.7.5 Links and contacts
17 Managing a Wiki
17.1 Revision control
17.1.1 Managing commits
17.2 Finding the first Wiki commit
17.3 Rebasing the Wiki
17.3.1 Summarising the rebase process
17.3.2 Executing the rebase process
17.4 Wikis and search engine visibility
Appendices
B Full list of all emoji characters
B.1 Emojis, a brief explanation
B.1.1 Emoji short names
B.1.2 Emoji escape codes
B.1.3 Emoji variations
B.1.4 Emoji numbers
B.2 Emojis characters by category
Smileys and emotion
People and body
Component
Animals and nature
Food and drink
Travel and places
Activities
Objects
Symbols
Flags
B.3 Emoji characters by Unicode
C Segoe UI full character set
A note by the Author
C.1 Inserting Unicode characters
C.2 Characters U+00000 to U+00FFF
C.3 Characters U+01000 to U+01FFF
C.4 Characters U+02000 to U+02FFF
C.5 Characters U+03000 to U+09FFF
C.6 Characters U+0A000 to U+0AFFF
C.7 Characters U+0B000 to U+0FFFF
C.8 Characters U+10000 to U+10FFF
C.9 Characters U+11000 to U+11FFF
C.10 Characters U+12000 to U+12FFF
C.11 Characters U+13000 to U+15FFF
C.12 Characters U+16000 to U+1CFFF
C.13 Characters U+1D000 to U+1EFFF
C.14 Characters U+1F000 to U+3FFFF
⬇️ End of page |