Javatpoint Logo
Javatpoint Logo

Tables in Markdown

The tables in markdown are similar to the tables created in the Microsoft word, which is the processing software to write the text in different styles, colors, and other formatting styles.

The line breaks in Markdown are used to create a cell in a table. We generally start with a cell, multiple columns in a row, and further multiple rows, which forms a table. Let's discuss the steps to create cells in a table.

  • Creating a cell

For example,

The two line breaks produce a cell, as shown below:

Tables in Markdown
  • Creating multiple cells

Similarly, the other cells adjacent to the above cells can be created using the line breaks. It forms a row with multiple columns.

The seven line breaks creates six columns, as shown below:

Tables in Markdown

Number of columns = number of line breaks - 1

  • Creating two rows

The rows can be created by adding the line breaks downwards. The two line breaks represent a cell, and another two line breaks below it represents the other. But, we need to add a dashed line to create further rows.

For example,

The output of the above syntax of line breaks is two rows, as shown below:

Tables in Markdown
  • Creating multiple rows

The multiple rows are created by adding line breaks one below the other.

For example,

The output of the above syntax of line breaks is two rows, as shown below:

Tables in Markdown

Creating a table

Let's create a table from the above four steps.

Output

The output of the above code is shown below:

Tables in Markdown

Text Alignment in Tables

We can align the text to the left, middle, or right side in a table using the ':' colon. We need to insert the colon on the respective side of the dash column (- - - -). By default, the text is aligned to the left.

Let's discuss the alignments in detail.

Left side alignment

To align the text on the left side, we need to insert a colon (:) at the left corner of the dash column (- - - -).

For example,

Output:

Tables in Markdown

Middle alignment

To align the text in the middle, we need to insert a colon (:) both at the left and right corner of the dash column (- - - -).

For example,

Output:

Tables in Markdown

Right side alignment

To align the text on the right side, we need to insert a colon (:) at the right corner of the dash column (- - - -).

For example,

Output:

Tables in Markdown

Similarly, we can create tables using the above commands.







Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA