Tables & Column Alignment Syntax
Tables are indispensable for summarizing product features, comparing technical specifications, displaying benchmarks, and documenting API parameters. While original Markdown omitted tables, GitHub Flavored Markdown (GFM) established the universal pipe-and-hyphen table standard.
1. The Anatomy of a GFM Table
A GFM table consists of three distinct components:
- 1Header Row: Defines column labels separated by pipes (
|). - 2Separator / Divider Row: A line of hyphens (
---) and colons that defines column boundaries and text alignment. - 3Data Rows: Rows of content separated by pipes.
2. Column Alignment Syntax (The Colon Rules)
The placement of colons (:) inside the second divider row controls how the entire column is aligned:
| Syntax in Separator | Alignment Direction | Best Used For |
|---|---|---|
:--- | Left-Aligned (Default) | General text, names, descriptions, titles |
:---: | Center-Aligned | Status badges, short codes, dates, yes/no flags |
---: | Right-Aligned | Numbers, prices, quantities, file sizes |
3. Formatting Text Inside Table Cells
You can use most inline Markdown elements inside table cells:
- Bold / Italic:
| **Bold** | *Italic* | - Inline Code:
|const x = 10;| File path | - Hyperlinks & Badges:
| [Documentation](https://...) |  | - Line Breaks inside a cell: Use raw
<br />tags (pressing Enter will create a new row!).
|) in Cell Data?
If your code or text contains a pipe (like a TypeScript union or bitwise OR), escape it with a backslash: \|!
Example: | Type | string \| number |Multiple Choice Questions
1. Which character is used to separate columns in a GitHub Flavored Markdown table?
A. Slash (/) B. Pipe (|) C. Ampersand (&) D. Tilde (~) Answer: B Explanation: The pipe character (|) acts as the column boundary delimiter in GFM tables.
2. How do you right-align a column in a Markdown table?
A. Place a colon on the right side of the separator row: '---:' B. Type 'align=right' C. Press Spacebar 20 times D. Use double pipes (||) Answer: A Explanation: Placing a colon on the right side of the hyphen separator (---:) aligns all content in that column to the right.
3. What is the minimum number of hyphens required per cell in the table separator row?
A. 1 hyphen B. 3 hyphens (e.g. '---') C. 10 hyphens D. 50 hyphens Answer: B Explanation: CommonMark and GFM specifications require at least three hyphens in each cell of the delimiter row.
4. How do you insert a line break inside a single table cell without breaking the row?
A. Press Enter B. Use an HTML '<br />' tag C. Type \newline D. Tables do not allow line breaks Answer: B Explanation: Pressing Enter begins a new table row, so an explicit HTML <br /> tag must be used for intra-cell line breaks.
5. How do you include a literal pipe character ('|') inside a table cell without splitting the column?
A. Escape it with a backslash: '\|' B. Write the word 'pipe' C. Close the table D. Use a comma Answer: A Explanation: A backslash before the pipe (\|) prevents the parser from treating it as a column delimiter.
Footnotes & Citation References
Continue learning with hands-on practice, examples, and exercises in the upcoming topic.
Related Lessons
| Previous Lesson | Next Lesson |
|---|---|
| Mathematical Notation with LaTeX / KaTeX | Footnotes & Citation References |
Practice Quiz
Test your understanding of this lesson with 5 questions. Each question has one correct answer.